source: trunk/minix/commands/scripts/rotate.sh@ 11

Last change on this file since 11 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

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