#! /bin/sh # bkpp - possibly backup a file with bkp # doesn't work with filenames containing whitespace # for f in $*; do test -r "$f" || { echo "$me Warning: cannot read $f" 1>&2 continue } b=`basename $f` last=`ls $f* | perl -w -n -e "print if /$b.\d{8}$/; print if /$b.\d{8}_\d+$/" | sort | tail -n 1` if test -z "$last" || ! cmp $f $last > /dev/null 2>&1; then bkp $f fi done