mkov

Often when working with something that's not CVS'd I copy the filename and append the date just like most people to preserve a copy of the original, just in case... To keep key strokes to a minimum this script does the job for me :-)

e.g.

fotter% mkov motd

creates a copy of the file called motd.PRE-YYYYMMDD. If motd.PRE-YYYYMMDD already exists it creates motd.PRE-YYYYMMDDvX where X is the next available version number.

#!/bin/bash
# mkov - MaKe Old Version
# fotter 20051117

if [ -z "$1" ]; then
        echo usage: $0 filename
        exit
fi

FILENAME=$1
POSTFIX=.PRE-$(date +%Y%m%d)
CPFILENAME=$FILENAME$POSTFIX
INC=1

while [ -e "$CPFILENAME" ]; do
        CPFILENAME=$FILENAME$POSTFIX\v$INC
        let INC=INC+1
done

cp $FILENAME $CPFILENAME

back to main page


fotter at iter1.com