Cover V01, I01
Article
Listing 1
Listing 10
Listing 11
Listing 12
Listing 13
Listing 14
Listing 15
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

may92.tar


Listing 12

#
# fleave.sh: leave n newest files in current directory, remove others
# usage: fleave.sh  dirname  #-to-leave
#

[ $# -ne 2 ] && echo "usage: $0 <dir> <# to leave>" && exit 1
[ ! -d "$1" ] && echo "$0: $1 is not a directory" && exit 1
[ $2 -lt 5 ] && echo "$0: cannot leave less than 5 files." && exit 1

cd $1
n=$2
temp=`tmpname flv`
ls -t | awk '{ if (NR > '$n') print "rm " $1}' >$temp
sh <$temp
rm $temp