minix/commands/scripts/rotate.sh

28 lines
370 B
Bash
Raw Normal View History

2005-08-12 15:28:37 +02:00
#!/bin/sh
RM="rm -f"
MV="mv -f"
if [ $# -ne 2 ]
then echo "Usage: $0 <log> <keep>"
exit 1
fi
if [ ! -f "$1" ]
2005-08-12 19:49:07 +02:00
then exit 1
2005-08-12 15:28:37 +02:00
fi
if [ "$2" -le 0 ]
then echo "Keep at least 1 copy please."
exit 1
fi
k="$2"
2005-08-12 19:49:07 +02:00
$RM "$1.$k" 2>/dev/null || exit 1
2005-08-12 15:28:37 +02:00
while [ "$k" -ge 2 ]
do prev="`expr $k - 1`"
$MV $1.$prev.gz $1.$k.gz 2>/dev/null
k=$prev
done
gzip -c $1 >$1.1.gz && : >$1