John Mort wrote:
> I'm trying to write a script that will dump one of my databases, then
> check to see if anything has changed since the last time the script
> ran (the idea being to remove duplicate backups to save disk space).
> Using cmp isn't an option because apparently some small number of bits
> are always changing so each dump is "unique".   So I'm trying to just
> compare the file sizes, but I'm apparently doing something wrong.  Any
> help would be appreciated.

Checking the size of a file isn't good enough to determine if the file
has not changed.   I would recommend taking an md5 checksum of the file
and comparing that.  Note that both of the following files are identical
in size but the checksum is different.   There is 1 blank that I
converted to a # that is different.

 [EMAIL PROTECTED]:~/mpi$ ls -l *.c
 -rw-r--r-- 1 jimd jimd 649 2008-02-16 23:32 demo.c
 -rw-r--r-- 1 jimd jimd 649 2007-06-30 23:57 SayHello.c
 [EMAIL PROTECTED]:~/mpi$ md5sum demo.c
 2862a1e0c5140ce61715952a8721985f  demo.c
 [EMAIL PROTECTED]:~/mpi$ md5sum MPIHello.c
 5221af4a8906d20bb5fecf84f9ab6a53  MPIHello.c
 [EMAIL PROTECTED]:~/mpi$


Jim

> 
> The code:
> 
> if $(stat -c%s $olddump) -eq $(stat -c%s $newdump)
> then
> echo No changes.
> else
> echo File has changed.
> fi
> 
> 
> The error:
> $ sh foo.shell
> foo.shell: 25: 875479: not found
> Backing up changes.
> 
> 
> Right now the files are equal size, so it should say "No changes."
> 875479 is the size of the files. I've tried dumping the stat command
> results into variables and comparing the variables, but I still get
> this same error message.  My googlemancy isn't powerful enough to come
> up with the answer on my own. :-/
> 


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mid-Hudson Valley Linux Users Group                  http://mhvlug.org          
   
http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug                           
Upcoming Meetings (6pm - 8pm)                         MHVLS Auditorium          
        
  Feb 6 - DBUS
  Mar 5 - Setting up a platform-independent home/small office network using 
Linux

Reply via email to