Skip to content

Instantly share code, notes, and snippets.

@Manojbhat09
Last active September 24, 2020 06:30
Show Gist options
  • Save Manojbhat09/72b0e9145085bbda3b0917f5bbeb3bc6 to your computer and use it in GitHub Desktop.
Save Manojbhat09/72b0e9145085bbda3b0917f5bbeb3bc6 to your computer and use it in GitHub Desktop.
Basic ubunu bash commands
# Delete all but the most recent X files in bash
ls -tp | grep -v '/$' | tail -n +6 | xargs -I {} rm -- {}
# +1 keeps 0 files, +4 keeps top 3 files
# https://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment