Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  Downloads
    Scripts
      Korn

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


AIX FREE DEMO UNIX
Automated AIX Deployment
Reduce your DC costs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

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"

-
Code Versioning
-
 


AIX FREE DEMO UNIX
Automated AIX Deployment
Reduce your DC costs

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com