#!/bin/ksh
#
# $Revision: 1.3 $ $Date: 2012-07-26 17:11:47-04 $
# $Source: /home/vogelke/bin/RCS/bak,v $
# $Host: sys7.com $
# $UUID: 759fedb4-395a-339e-aa89-3205d828e00a $
#
#<bak: make a quick backup.  Needs one existing file as an argument.

case "$#" in
    1) file=$1 ;;
    *) echo need one existing file; exit 1 ;;
esac

test -f "$file" || { echo $file not found; exit 2; }
nd=$(date '+%Y%m%d%H%M')

case "$file" in
    *.*) base="${file%.*}"; ext="${file##*.}"; nfile="$base.$nd.$ext" ;;
    *)   nfile="$file.$nd" ;;
esac

cp -p $file $nfile && echo $nfile
exit 0
