How To Use Meld To Compare Changes In Files On Linux
If you do a lot of development or code auditing on Linux, searching through code to find subtle changes can be very tedious. Luckily, there’s an easy solution: just use Meld. With Meld you can quickly detect changes in files, directories and more.
Install Meld
To use Meld, you need to be running either Ubuntu, Debian, Arch Linux, Fedora, OpenSUSE or a Linux OS that can install Flatpaks.
Ubuntu
sudo apt install meld
Debian
sudo apt-get install meld
Arch Linux
Getting the Meld application on Arch Linux isn’t possible without enabling the “Extra” software source. This repository is often shut off by default on many Arch installations, as it has software not critical to the majority of systems.
Turning on the Extra software source is done by making a small edit to the Pacman configuration file. To do this, open up a terminal and gain root access with the su command. If you choose not to allow su, a sudo -s will suffice.
su -
or
sudo -s
Using your root access, open up the Pacman configuration file in the Nano text editing application.
nano /etc/pacman.conf
In Nano, use the down arrow keys to navigate down the file Search for the “Extra” entry. There are three lines to the “Extra” repo. Remove all # symbols from in front of the lines, and press Ctrl + O to save your changes. Exit the editor by pressing Ctrl + X, and re-sync the Arch packaging tool.
pacman -Syy
Running a re-sync downloads new repository information for already set up software repos. It’ll also download the package listings and set up Extra. When that’s taken care of, it’s safe to install the Meld application to Arch Linux.
pacman -S meld
Fedora
sudo dnf install meld
OpenSUSE
sudo zypper install meld
Generic Linux via Flatpak
Meld is a part of the Gnome project, so the software finds its way on just about every Linux distribution in the form of a native binary package. However, if you’re on a Linux distribution that for some reason doesn’t have access to a native installer, the next best thing is to get the app via Flatpak.
Before installing Meld via Flathub, follow our guide to learn how to set up the Flatpak packaging system on your Linux PC. When you’ve got Flatpaks working, open up a terminal and enter the following commands to install Meld.
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub org.gnome.meld
After running the commands above to install Meld, launch it for the first time with:
flatpak run org.gnome.meld
Use Meld To Compare Files
Meld’s primary purpose is to find subtle differences in text, and it can detect changes very quickly. Better still, Meld has support for lots of different types of text and file types, ensuring that no matter what, your changes are detectable.
If you’re not sure how to check for “differences” in files in the Meld application, follow these steps.
Step 1: In the Meld start-up page, look for “file comparison”. Under the “file comparison” option, you’ll notice a button that says “none”. Click it and use it to browse for the first file in your comparison.
Step 2: Loading up the first file into meld will transform the app into a split-screen mode. On the left side of the split-screen, you’ll see the first file you’ve added. On the right, you’ll see a blank page. Click the title of the page and load up the file you want to compare with the one from earlier.
Step 3: When the two files finish loading into Meld, it’ll highlight changes it sees in the text with the color blue, and similarities with lime green. Scroll through, and look at the text. If you’re unhappy with differences, click the arrow icon above the “diff” and allow Meld to change it.
When you’re satisfied with the changes you’ve made with Meld, click the “save” button.
Use Meld To Compare Directories
Aside from checking various files for differences in text, Meld can find differences in directories. Directory comparison is a handy feature if you’re trying to keep two different folders the same, but can’t tell if they have the same contents.
To use this feature, launch Meld, look to the start-up screen, and click the “directory comparison” button.
After selecting “directory comparison”, two boxes with “none” will appear. Click on both of the boxes and use the menu to set the folders you’re trying compare. When the folders are set, click “compare”, and the Meld application will instantly load both folders and highlight the differences in both directories.
Copy Files/Folders
Need to copy a file or folder from one side to the other? Scroll through the list, select a directory or file, and right-click on it. After right-clicking, click on the “copy to” option to move the data.
To clarify: click the left none button, then select OTHER, then browse to the file or folder. Then repeat for the middle none button. If doing a folder compare you want to browse to the parent and select/highlight your target folder, then click OPEN in the upper right.