How to compare directories with binary files
This can easily be done with diff
. For example:
$ ls -l foo/
total 2132
-rwxr-xr-x 1 terdon terdon 1029624 Nov 18 13:13 bash
-rwxr-xr-x 1 terdon terdon 1029624 Nov 18 13:13 bash2
-rwxr-xr-x 1 terdon terdon 118280 Nov 18 13:13 ls
$ ls -l bar/
total 1124
-rwxr-xr-x 1 terdon terdon 1029624 Nov 18 13:14 bash
-rwxr-xr-x 1 terdon terdon 118280 Nov 18 13:14 ls
$ diff bar/ foo/
Only in foo/: bash2
In the example above, the foo/
and bar/
directories contain binary files and bash2
is only in foo/
.
So, you could run something simple like:
$ diff bar/ foo/ && echo "The directories' contents are identical"
That will show you the different files, if any, or print "The directories' contents are identical" if they are. To compare subdirectories and any files they may contain as well, use diff -r
. Combine it with -q
to suppress the output for text files.