Home> System Tutorial> LINUX> body text

Use the Diff and Meld tools to compare the differences between two directories

WBOY
Release: 2024-08-21 16:39:30
Original
293 people have browsed it

Generally, to compare two files under Linux, we will usediff(a simple command line tool derived from Unix) to display the differences between two computer files; It compares files line by line and is very easy to use. It is pre-installed in almost all Linux distributions.

The question is how can we compare two directories under Linux? Now, we want to know which files/subdirectories are common to both directories and which ones only exist in one directory.

The general syntax for running diff is as follows:

$ diff [OPTION]… FILES $ diff options dir1 dir2
Copy after login

By default, the output is sorted alphabetically by the file name of the file/subfolder, as shown in the screenshot below, in the command, the-qswitch is telling # #diifOnly report if files have differences.

$ diff -q directory-1/ directory-2/
Copy after login

使用 Diff 和 Meld 工具比较两个目录的不同处

Difference between two folders

Running

diffagain does not allow us to enter the subfolder, but we can use the-rswitch to read the subfolder, as shown below.

$ diff -qr directory-1/ directory-2/
Copy after login
Use Meld visual comparison and merging tool

meldis a cool graphical tool (a visual comparison and merge tool under the GNOME desktop) for those who like to use the mouse. You can install it as follows .

$ sudo apt install meld [Debian/Ubuntu systems] $ sudo yum install meld [RHEL/CentOS systems] $ sudo dnf install meld [Fedora 22+]
Copy after login
Once you have it installed, search for "

meld" inUbuntu Dashor the Linux Mint menu, or the Activities Overview of the Fedora or CentOS desktop, and launch it.

You can see the following Meld interface, where you can select files or folders to compare, and there is also a version control view. Click Directory Compare and move to the next interface.

使用 Diff 和 Meld 工具比较两个目录的不同处

Meld comparison tool

Select the folder you want to compare. Note that you can check the "

3-way Comparison" option to add a third folder.

使用 Diff 和 Meld 工具比较两个目录的不同处

Select the folder to compare

After selecting the folders to compare, click “Compare”.

使用 Diff 和 Meld 工具比较两个目录的不同处

Different list of folders

In this article, we describe how to find the difference between two folders in Linux. If you know of other commands or GUI tools, don’t forget to share your thoughts in the comments below.


The above is the detailed content of Use the Diff and Meld tools to compare the differences between two directories. For more information, please follow other related articles on the PHP Chinese website!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!