Looking Out for Potholes

Monday, July 30, 2012

Bash: Delete oldest 5 files in a directory

After a bit of searching, I found quite a few options.  This was simple and got the job done.


find /directoryName -type f | awk 'NR>5'|xargs rm -f
Posted by John at 1:32 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2015 (1)
    • ►  April (1)
  • ►  2014 (2)
    • ►  July (1)
    • ►  March (1)
  • ►  2013 (10)
    • ►  October (2)
    • ►  August (2)
    • ►  May (2)
    • ►  April (2)
    • ►  March (1)
    • ►  January (1)
  • ▼  2012 (6)
    • ▼  July (1)
      • Bash: Delete oldest 5 files in a directory
    • ►  March (1)
    • ►  February (4)
  • ►  2011 (15)
    • ►  December (2)
    • ►  November (1)
    • ►  October (3)
    • ►  September (1)
    • ►  August (1)
    • ►  July (1)
    • ►  April (3)
    • ►  January (3)
  • ►  2010 (10)
    • ►  October (2)
    • ►  September (1)
    • ►  August (7)
Awesome Inc. theme. Powered by Blogger.