This document contains the source code for the Disaster Recovery script "mkversion".
#!/usr/bin/ksh ################################################################ #### #### Program: mkversion: #### #### Description: #### #### Creates numbered versions of a file. The latest #### version has the lowest number following the file name. #### The oldest version has the highest number following the #### file name. #### #### Author: Dana French (dfrench@mtxia.com): #### #### Date: 06/17/2003: #### ################################################################ FNAME="${1:?ERROR: Syntax \"${0} fileName\"}" [[ ! -f ${FNAME} ]] && echo "ERROR: ${FNAME} does not exist" && exit 1 for F in $( ls -1r ${FNAME}.+([0-9]) 2>/dev/null ) do [[ ! -w ${F} ]] && echo "ERROR: ${F} is not writeable" && exit 2 [[ ! -r ${F} ]] && echo "ERROR: ${F} is not readable" && exit 3 [[ ! -w . ]] && echo "ERROR: . is not writeable" && exit 4 done for F in $( ls -1r ${FNAME}.+([0-9]) 2>/dev/null ) do cp ${F} ${FNAME}.$(( ${F#${FNAME}.} + 1 )) || exit 5 done cp "${FNAME}" "${FNAME}.0"
This file last modified 02/04/09