Home About BC DR HA Support Training Download
You are here: Home/ Downloads/ Scripts/ Korn/ Please Login or Register

-
Current Location
-

js
  Downloads
    Scripts
      Korn



-
 Mt Xia Inc.
-
BOOK:Advanced Shell Scripting



 Join our LinkedIn Group
AIX Advanced Technical Experts
Contract Opportunities

www.LinkedIn.com
-
 Train By Tweet
Training courses Tweet By Tweet
Various Subjects and Products
TrainByTweet.com


AIX Admin Methodology
Global Consolidation Project
All AIX admins should join
www.aixexpert.com
-

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

LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

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

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com

mkversion

The following is a simple shell script to easily create backup copies of a file. Each copy of the file is sequentially numbered with the most recent versions having the lowest numbers. This version of the "mkversion" script will keep up to 10,000 copies of a file.





#!/usr/bin/ksh93
################################################################
# Program: mkversion_k93
# 
# Description: Creates numbered versions of a file (up to 9999).
# 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
# Last Modified: 06/29/2015
# 
################################################################
FNAME="${1:?# ERROR: Syntax \"${0} fileName\"}"
[[ ! -f ${FNAME} ]] && print -u 2 -- "# ERROR: ${FNAME} does not exist" && exit 1

F=( ${FNAME}.[0-9] ${FNAME}.[1-9][0-9] ${FNAME}.[1-9][0-9][0-9] ${FNAME}.[1-9][0-9][0-9][0-9] )
for (( i=${#F[@]}; i>=1; --i ))
do
  [[ ! -e ${F[i-1]} ]] && unset F[i-1] && continue
  [[ ! -w ${F[i-1]} ]] && print -u 2 -- "# ERROR: ${F[i-1]} is not writeable" && exit 2
  [[ ! -r ${F[i-1]} ]] && print -u 2 -- "# ERROR: ${F[i-1]} is not readable" && exit 3
  [[ ! -w . ]] && print -u 2 -- "# ERROR: . is not writeable" && exit 4
done

for (( i=${#F[@]}; i>=1; --i ))
do
  cp ${F[i-1]} ${FNAME}.$(( ${F[i-1]#${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

LPAR Leasing
Lease an AIX / i5 LPAR
Reduce your costs

www.mtxia.com

Server Leasing
Lease a Server off-site
Reduce your costs

www.mtxia.com

Data Center Automation
Business Continuity and DR
Virtualization/Consolidation

www.mtxia.com

HMC Service
Hardware Management Console
Manage Remote AIX / i5 LPARs

www.siteox.com

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

www.siteox.com

Disaster Recovery
Small Business Oriented
Off-Site Facilities

www.mtxia.com

IBM pSeries / iSeries
Reduce your Costs
Off-Site Server Hosting

www.mtxia.com