Skip to content

Instantly share code, notes, and snippets.

@lambdamusic
Created February 7, 2013 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lambdamusic/4734299 to your computer and use it in GitHub Desktop.
Save lambdamusic/4734299 to your computer and use it in GitHub Desktop.
Bash: Command line delete matching files and directories recursively
# This searches recursively for all directories (-type d) in the hierarchy starting at "." (current directory), and finds those whose name is '.svn'; the list of the found directories is then fed to rm -rf for removal.
find . -name '.svn' -type d | xargs rm -rf
# If you want to try it out, try
find . -name '.svn' -type d | xargs echo
# This should provide you with a list of all the directories which would be recursively deleted.
==================================
# Another way is:
find . -name ".svn" -exec rm -rf {} \;
#Try something like this first to do a dry run:
find . -name ".svn" -exec echo {} \;
#Note that the empty braces get filled in with the file names and the escaped semicolon ends the command that is executed (starting after the "-exec").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment