Remove unix files but leave the most recent ones
Posted on February 8th, 2008I need to use it to delete saparch directory as it becomes full every several hours during big loading/compression/ods activation etc. It should only be used in staging and dev. On prod, need another approach — backup everything in saparch, backup to tape, then clean up archive.
#!/usr/bin/ksh
# server SID
echo $1
# files to be kept
echo $2
cd /oracle/$1/saparch
cnt=`ls -1 $1arch*.dbf [...]