To delete all files in inc older than the second oldest file in full, you do:
find /path-to/inc -type f ! -newer `ls -1t /path-to/full | tail -2 | head 1` -exec rm {} \;
PS: ! -newer = older
ls -1t /path-to/full | tail -2 | head 1 # 2nd oldest
ls -rt will give 2nd newest one!
Main Topics
Browse All Topics





by: tfewsterPosted on 2005-02-25 at 00:25:31ID: 13400965
shell-independant:
find /inc -newer `ls -lrt /full |tail -2 |head -1|awk '{print $NF}'` -exec rm {} \;