Thursday, 25 June 2015

Comparing Files using Find and CMP

I needed to compare two directories containing binary files. Rsync was confusing, Diff only compares text-files.

I tried the following:
# Example: ~/ FC30-3DA9
# where $1 is the directory name
# requirement: you are in one of the two parent dirs.
# the directories to compare must have the same name

find $1 -type f -exec sh -c '
  for f; do
    cmp "$f" /directory/of/mr/bear/"$f"
' sh {} +
Seemed to work fine.


How to compare files in two folders using cmp?

No comments:

Post a Comment