Skip to content

Instantly share code, notes, and snippets.

@sarathlal-old
Created April 5, 2018 06:51
Show Gist options
  • Save sarathlal-old/c2dd5ca0152566d60c183d3e6ac89ac2 to your computer and use it in GitHub Desktop.
Save sarathlal-old/c2dd5ca0152566d60c183d3e6ac89ac2 to your computer and use it in GitHub Desktop.
find . ! -name 'file.txt' -type f -exec rm -f {} +
will remove all regular files (recursively, including hidden ones) except file.txt. To remove directories, change -type f to -type d and add -r option to rm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment