The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-09-2008
Franklin52 Franklin52 is offline
Moderator
 

Join Date: Feb 2007
Posts: 2,474
Ok, some hints:

To find older files you can use the find command with the -mtime option.
To keep 5 files of the selection you can pipe the result to awk, to ignore the first 5 files you can do something like:

Code:
awk 'NR<6{next}{print}'
So it should look like:

Code:
find <options> | awk '....' | rm -f
If you have many files you can use xargs.

Code:
...| xargs rm -f
Check the man page of find for the options, search on this forum or Google for examples.


Regards
Reply With Quote