Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare contents of two directoriers in bash?

Lets say there are two dirs

/path1 and /path2

for example

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

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

And one needs to know if they are identical by contents (names of files and content of files) and if not have differences listed.

How to do this in Linux? Is there some Bash/Zsh command for it?

like image 855
Bohdan Avatar asked May 09 '13 23:05

Bohdan


2 Answers

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

like image 198
Lynch Avatar answered Sep 28 '22 12:09

Lynch


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

rsync -avni /path1/ /path2

This program will normally sync two folders, but with -n it will do a dry-run instead.

like image 25
Robert Gomez Avatar answered Sep 28 '22 11:09

Robert Gomez