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

2004/10/24 cmp


Some material is very old and may be incorrect today

© October 2004 Tony Lawrence

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.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> cmp


Inexpensive and informative Apple related e-books:

Take Control of Automating Your Mac

Take Control of IOS 11

Take Control of the Mac Command Line with Terminal, Second Edition

Photos for Mac: A Take Control Crash Course

iOS 8: A Take Control Crash Course





More Articles by © Tony Lawrence





Printer Friendly Version

Have you tried Searching this site?

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


Printer Friendly Version





Much to the surprise of the builders of the first digital computers, programs written for them usually did not work. (Rodney Brooks)




Linux posts

Troubleshooting posts


This post tagged:

Shell

UnixWords



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode