Robert P. J. Day wrote:
Well, since I'm done creating the script, and it works as it should, I may as well start doing some house cleaning and simplifynig things. One of the routines in the script basically runs through a FOR loop, setting index numbers (that $idx above). What this particular routine does is this:just to tighten things up, you might consider any or all of the following:1) use the sequential && (and) operator: (or not, personal taste here) [ -d $SNAPSHOT/daily.$idx ] && $MV $SNAP ... etc etc ... ^^ command sequencing (or whatever it's called) 2) use the curly brace expansion operator to filter out common stuff: $MV $SNAPSHOT/daily.{$idx,$((idx+1))} # the entire $MV command
- Creates a loop for the file systems being dumped
- Creates the $idx needed
- Use that $idx to do that $MV command above
However, I'm a nit picker and I prefer my numbers to be padded, so I'm having to do some convoluted thing to get my padding to work. Looking at my FOR loop, I'm not sure this is the correct way to do things, nor whether it's the most efficient way of doing it. Here goes:
# LOOP through the following directories
for fs in root etc boot yp mysql apache mail home ; do
# LOOP through the 13 (latest) days of the backup
for ((idx=13 ; idx >= 2; idx--)) ; do
# create next ($nidx) and a var for $pidx (padded $idx)
# for some reason if I just use $idx (instead of $pidx, it fails)
nidx=$((idx+1));
pidx=$idx;
# see if either $pidx or $nidx needs padding
if [ "$nidx" -lt "10" ] ; then
nidx=0$nidx;
fi
if [ "$pidx" -lt "10" ] ; then
pidx=0$pidx;
fi
# Move things around.
if [ -d $SNAPSHOT_RW/$fs/daily.$pidx ] ; then
$MV $SNAPSHOT_RW/$fs/daily.$pidx $SNAPSHOT_RW/$fs/daily.$nidx ;
fi;
done
done
--
W | I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list