How to compare the contents of two editors in bash?

Let's say there are two dirs

/path1 and /path2 

eg

 /path1/bin /path1/lib /path1/... /path2/bin /path2/lib /path2/... 

And you need to know if they are identical in content (file names and file contents), and if differences are not indicated .

How to do it on Linux? Is there a Bash / Zsh command for this?

+4
source share
3 answers

The diff command can show all the differences between the two directories: diff -qr /path1 /path2

+5
source

Someone already suggested this, but deleted their answer, not knowing why. Try using rsync :

 rsync -avni /path1/ /path2 

This program will usually synchronize the two folders, but with -n will perform a dry start instead.

+3
source

I use this script for such a task:

 diff <(cd "$dir1"; find . -type f -printf "%p %s\n" | sort) \ <(cd "$dir2"; find . -type f -printf "%p %s\n" | sort) 

Feel free to customize the script in the <(...) for your specific needs. This version uses find to print the contents of a directory by printing the paths and file sizes found in it. Of course, other things are possible.

+1
source

Source: https://habr.com/ru/post/1480011/


All Articles