[comp.unix.programmer] Can you 'checksum' a file to see if it was changed?

bill@twg.bc.ca (Bill Irwin) (05/27/91)

I would like to know if there is a command under SCO XENIX 2.3.3
that will produce a checksum on a file, so that later, another
checksum could be compared to the first;  and if different, you
would know that the file had been modified.

Looking at the byte size of the file is a fairly good indicator
if it has been modified, but changes can be made to files that
leave the byte size the same.

Ideally, the command would produce a checksum that could be
stored in a file along with the checked file's name.  Is there
such a beast?
-- 
Bill Irwin    -       The Westrheim Group     -    Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!van-bc!twg!bill     (604) 431-9600 (voice) |     Your Computer  
bill@twg.bc.ca            (604) 430-4329 (fax)   |    Systems Partner

slootman@dri.nl (Paul Slootman) (05/27/91)

In article <2286@twg.bc.ca> bill@twg.bc.ca (Bill Irwin) writes:
>I would like to know if there is a command under SCO XENIX 2.3.3
>that will produce a checksum on a file, so that later, another
>checksum could be compared to the first;  and if different, you
>would know that the file had been modified.

There is a command 'sum' that (surprise!) calculates the checksum.
Some versions have an option -r that causes an alternative
algorithm to be used, which is better at detecting things like
swapped bytes and so (I think, not rely on this). SCO Unix has
this option, I'm not sure about Xenix.

I'm not sure this is the right newsgroup for this... comp.unix.shell?

Paul.
-- 
 ----------------
:slootman@dri.nl : When you get to the point where you think that nothing
:+ 31 5496 88831 : is impossible, try pushing toothpaste back into a tube
 ----------------

bill@twg.bc.ca (Bill Irwin) (05/28/91)

The answer to this was sitting in my mailbox when I got into the
office the morning after posting.  Talk about service!

There is a "sum" command that will output a checksum for a file.
-- 
Bill Irwin    -       The Westrheim Group     -    Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!van-bc!twg!bill     (604) 431-9600 (voice) |     Your Computer  
bill@twg.bc.ca            (604) 430-4329 (fax)   |    Systems Partner

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (05/29/91)

bill@twg.bc.ca (Bill Irwin) writes:

>The answer to this was sitting in my mailbox when I got into the
>office the morning after posting.  Talk about service!
>
>There is a "sum" command that will output a checksum for a file.

This is a useful command, too.  For instance I use it in my crosslink
script which first checks files for like sizes, and if alike, then it
takes the checksum to see if they still might be alike.  The first
file is summed only once a second file is found of the same size.
If the sums match, then the files are compared with "cmp" for the
final determination.  If they are identical, they are hardlinked.
Cuts down on space in some cases.
-- 
 /***************************************************************************\
/ Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu   |  Guns don't aim guns at  \
\ Lietuva laisva -- Brivu Latviju -- Eesti vabaks  |  people; CRIMINALS do!!  /
 \***************************************************************************/