Rev | Line | |
---|
[9] | 1 | #!/bin/sh
|
---|
| 2 | BZIP=/usr/local/bin/bzip2
|
---|
| 3 | RM="rm -f"
|
---|
| 4 | MV="mv -f"
|
---|
| 5 |
|
---|
| 6 | if [ $# -ne 2 ]
|
---|
| 7 | then echo "Usage: $0 <log> <keep>"
|
---|
| 8 | exit 1
|
---|
| 9 | fi
|
---|
| 10 |
|
---|
| 11 | if [ ! -f "$1" ]
|
---|
| 12 | then exit 1
|
---|
| 13 | fi
|
---|
| 14 |
|
---|
| 15 | if [ ! -x "$BZIP" ]
|
---|
| 16 | then exit 1
|
---|
| 17 | fi
|
---|
| 18 |
|
---|
| 19 | if [ "$2" -le 0 ]
|
---|
| 20 | then echo "Keep at least 1 copy please."
|
---|
| 21 | exit 1
|
---|
| 22 | fi
|
---|
| 23 |
|
---|
| 24 | k="$2"
|
---|
| 25 | $RM "$1.$k" 2>/dev/null || exit 1
|
---|
| 26 | while [ "$k" -ge 2 ]
|
---|
| 27 | do prev="`expr $k - 1`"
|
---|
| 28 | $MV $1.$prev.bz2 $1.$k.bz2 2>/dev/null
|
---|
| 29 | k=$prev
|
---|
| 30 | done
|
---|
| 31 | $BZIP -c $1 >$1.1.bz2 && : >$1
|
---|
Note:
See
TracBrowser
for help on using the repository browser.