Created
February 7, 2013 21:25
-
-
Save lambdamusic/4734299 to your computer and use it in GitHub Desktop.
Bash: Command line delete matching files and directories recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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