Command line delete matching files and directories recursively


/ Published in: Bash
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # 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.
  2.  
  3. find . -name '.svn' -type d | xargs rm -rf
  4.  
  5. # If you want to try it out, try
  6.  
  7. find . -name '.svn' -type d | xargs echo
  8.  
  9. # This should provide you with a list of all the directories which would be recursively deleted.
  10.  
  11. ==================================
  12.  
  13. # Another way is:
  14.  
  15. find . -name ".svn" -exec rm -rf {} \;
  16.  
  17. #Try something like this first to do a dry run:
  18.  
  19. find . -name ".svn" -exec echo {} \;
  20.  
  21. #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").

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.