Workflow: Using sed to Delete Specific File Patterns
Posted on 03/30/2009 @ 01:22PMI will often make backups of my sites on an external hard drive simply by copying and pasting them, then leaving the computer for an hour while everything copies. The sucky thing about that is that projects managed by subversion have hundreds of little hidden .svn directories, with tons of files in them.
Using sed we can easily remove all those .svn folders if we don't have a need for them. The following command works well:
find . -name .svn | sed 's/\(.*\)/rm -rf \1/' | sh
Note the double quotes; these ensure that paths with spaces in them will be included. Once again, we can test the command beforehand by omitting the sh, and we'll see all the commands output to the screen without being executed:
find . -name .svn | sed 's/\(.*\)/rm -rf \1/'