Skip to content

Instantly share code, notes, and snippets.

@smerchek
Created June 5, 2013 21:52
Show Gist options
  • Select an option

  • Save smerchek/5717610 to your computer and use it in GitHub Desktop.

Select an option

Save smerchek/5717610 to your computer and use it in GitHub Desktop.
Remove all but most recent number of files in a directory
# Keep 4 most recent files/sub-directories
# source: http://superuser.com/a/260332
ls -r1 | tail -n +5 | xargs rm -rf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment