2 # copy a file if it is both newer and bigger in size
3 # if copying, first rename older file to .orig
7 # dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime,ctime,blksize,blocks
11 $srcsize = $srcstat[7];
12 $srcmtime = $srcstat[9];
13 $dstsize = $dststat[7];
14 $dstmtime = $dststat[9];
16 # copy if src file is bigger and newer
17 if ($srcsize > $dstsize && $srcmtime > $dstmtime) {
18 print "mv -f $dst $dst.orig\n";
19 system("mv -f $dst $dst.orig");
20 print "cp -p $src $dst\n";
21 system("cp -p $src $dst");
22 die "cp command failed" if ($?
!= 0);
24 # make sure dst file has newer timestamp
25 if ($srcmtime > $dstmtime) {