APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2004/10/24 cmp

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
 


Got something to add? Send me email.




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





If we define Futurism as an exploration beyond accepted limits, then the nature of limiting systems becomes the first object of exploration. (Frank Herbert)





This post tagged: