0

How to list and compare the similar files from different directories using single command on Linux? Let's suppose there are three files a, b and c in directory /home/test and a, d, c files in another directory, /home/test1.

How can I list and compare similar files using a single command?

  • Are you interested in comparing the file contents or the file names, or some other aspect of the files? – Kusalananda Apr 13 at 12:08
  • Also, "similar" implies "almost the same". Could you elaborate on that? – Kusalananda Apr 13 at 13:46
1

This command will compare the file names in each directory and also report if any of the shared file names differ:

$ diff -qr /home/test /home/test1
Files /home/test/a and /home/test1/a differ
Only in /home/test: b
Only in /home/test1: d
0

kdiff3 is a good graphical tool. It can compare files and directories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.