Cover V02, I04
Article
Figure 1
Listing 1
Listing 2
Listing 3
Listing 4

jul93.tar


Listing 4: du_clean--Performs housekeeping on du output

#!/bin/sh
# du_clean: only keep 1 du output a month and the last DAYS
# complete (per filesystem), invoked from du_daily
# Usage: du_clean days_to_keep word_for_every_fs_to_keep....

DAYS=$1
shift

cd olddates

w=`expr $DAYS  /* $#`
w=`ls [0-9]* | tail -$w`

mkdir tmp

# move all files from the first to tmp
mv [0-9][0-9][0-9][0-9]01.* tmp 2>/dev/null
# move all selected files to tmp
mv $w tmp 2>/dev/null
rm -f * 2>/dev/null

mv tmp/* .
rmdir tmp