Wednesday, October 15, 2014

Linux: How to compare multiple files in given directories


In linux, any flavor you are using, you can find out the file's content differences in two directory.

For example :
You have directory "test1" and "test2" both contains the multiple files and directory.

And your problem is to find out files where content are mismatch with the "test1" directory's file.

So, do not worry about this. Linux provide a very powerful tool to find out the differences i.e diff command:

# diff -qrs test1/ test2/ 

-q : report only when files differ
-r : recursively compare any subdirectories found
-s : report when two files are the same

Above command will give you output in report format where files content differ or identical.

If you found something differ in your file in the final report, then you can run the below command to see the actual differences.

# diff test1/file1 test2/file1

No comments :