xref: /original-bsd/local/ukc/dump/cleanvolumes.sh (revision bbb96de4)
1#!/bin/sh
2#	cleanvolumes.sh	1.5	08/08/87
3#	shell script to clean dumpvolumes file
4#	This ensures that only the last entry for a
5#	particular tape is retained on the log
6#	Caveat Tape labels MUST not contain a colon
7#
8PATH=:/etc/:/bin:/usr/bin:
9#	Name of	logfile
10DL=/etc/dumpvolumes
11#	Name of tmp files
12DT=/tmp/dumpclean$$
13DE=/tmp/dumpedit$$
14export DT
15export DE
16trap "rm -f $DT $DE" 1 2 3 15
17sed -e 's/:.*$//' $DL |
18	sort |
19	uniq -c |
20	awk	'{	if ($1 != 1)
21			{
22				for (i = 0; i < $1-1; i++)
23					printf "$\n/%s/d\n", $2
24			}
25		}' > $DE
26if [ -s $DE ]
27then
28	cp $DL $DT
29	echo "w" >> $DE
30	echo "q" >> $DE
31	ed $DT < $DE > /dev/null
32	mv $DT $DL
33fi
34rm -f $DE
35