is it possible to nest a while in a for using bourne shell to rotate logfiles? The $LOG variable is not changing in the while loop:
N=4
I=`expr $N - 1`
for LOG in log1 log2 log3 ; do
while [ $I -ge 0 ] ; do
test -f $LOG.$I && mv $LOG.$I $LOG.$N
N=$I
I=`expr $I - 1`
done
test -f $LOG && mv && $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
done
N=4
I=`expr $N - 1`
for LOG in log1 log2 log3 ; do
while [ $I -ge 0 ] ; do
test -f $LOG.$I && mv $LOG.$I $LOG.$N
N=$I
I=`expr $I - 1`
done
test -f $LOG && mv && $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
done