I often forget about "cmp" and use "diff" when all I really want to know is if two files are the same:
cmp -s file1 file2 || echo "Not the same"
Often the reason for the comparison is that I've written something like this:
touch /tmp/testdirb.$$ while : do ls /testdir > /tmp/testdira.$$ cmp -s /tmp/testdira.$$ /tmp/testdirb.$$ || echo "changed" cp /tmp/testdira.$$ /tmp/testdirb.$$ sleep 300 done
If you found something useful today, please consider a small donation.
Got something to add? Send me email.
More Articles by Tony Lawrence © 2011-07-05 Tony Lawrence
Much to the surprise of the builders of the first digital computers, programs written for them usually did not work. (Rodney Brooks)