2005-08-12 15:28:37 +02:00
|
|
|
#!/bin/sh
|
2006-02-02 18:12:16 +01:00
|
|
|
BZIP=/usr/local/bin/bzip2
|
2005-08-12 15:28:37 +02:00
|
|
|
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
|
|
|
|
|
2006-02-02 18:12:16 +01:00
|
|
|
if [ ! -x "$BZIP" ]
|
|
|
|
then exit 1
|
|
|
|
fi
|
|
|
|
|
2005-08-12 15:28:37 +02:00
|
|
|
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`"
|
2006-03-22 17:44:45 +01:00
|
|
|
$MV $1.$prev.bz2 $1.$k.bz2 2>/dev/null
|
2005-08-12 15:28:37 +02:00
|
|
|
k=$prev
|
|
|
|
done
|
2006-03-22 17:44:45 +01:00
|
|
|
$BZIP -c $1 >$1.1.bz2 && : >$1
|