Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux find the difference between two directories

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Linux how to find the difference between the two directories", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux how to find the difference between the two directories" bar!

Typically, to compare two files in Linux, we use diff, a simple and primitive Unix command-line tool that shows you the differences between two computer files. Files are compared line by line and are easy to use, and the tool is preinstalled in most Linux distributions.

The question is how to get the difference between the two directories in Linux? Here, we want to know which files / subdirectories are shared between the two directories, which exist in one directory but not in the other.

The general syntax for running diff is as follows:

$diff [OPTION]... FILES $diff options dir1 dir2

By default, its output is arranged alphabetically by file / subdirectory name, as shown in the screenshot below. In this command, the-Q switch tells diff to report only if the file is not simultaneous.

Linuxmi@linuxmi:~/www.linuxmi.com$ diff-Q www.linuxmi.com/ linuxmi.com/

Exists only in www.linuxmi.com/: Blender 2.blend

It exists only in www.linuxmi.com/: Windows 10 vs Debian vs Arch Linux (EndeavourOS)-Speed testings copyright cQWwb8VRrhU.mkv

The difference between the two directories

Again, diff does not enter subdirectories, but we can use the-r switch to read subdirectories, like this.

Linuxmi@linuxmi:~/www.linuxmi.com$ diff-qr www.linuxmi.com/ linuxmi.com/

Use Meld to visualize differences and merge tools

There is a cool graphical option called meld (a visual difference and merge tool for GNOME desktops), which you can install as follows for those who like to use the mouse.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install meld [Debian/Ubuntu system]

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo yum install meld [RHEL/CentOS system] linuxmi@linuxmi:~/www.linuxmi.com$ sudo dnf install meld [Fedora 22 +]

After installation, search for "meld" in the Ubuntu Dash or Linux Mint menu in the activity Overview on the Fedora or CentOS desktop, and then start it.

You will see the Meld interface below, where you can select file or directory comparisons and version control views. Click the directory comparison, and then go to the next interface.

Select the directory you want to compare, and note that you can add a third directory by checking the "3-way comparison" option (as shown below).

Once you have selected the directory, click "compare".

Thank you for your reading, the above is the content of "Linux how to find the difference between the two directories", after the study of this article, I believe you have a deeper understanding of how Linux finds the difference between the two directories, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report