I could get to like this bash thing. I have a fairly deeply nested directory tree. I wanted to delete all directories within that tree with a given name. (.svn
, as it happens.) I was trying to use ls to generate a list of directories, but ls -R .svn
wasn't giving me anything.
So, I joined the #bash channel on freenode, and was steered in the right direction in seconds - use the find command. Here's the end result, for my own reference as much as anything:
yes | find . -name '.svn' -exec rm -r {} \;
Beautiful, no? Well, OK, no, but it works.
Posted to Mac by Simon Brunning at September 07, 2005 01:04 PMI almost always sling some python for stuff like this because it's portable between win/linux.
And as a matter of fact, I have a cleanCVS.py in my path right now.
Posted by: j on September 7, 2005 02:08 PMfind . -name '.svn' -exec rm -rf {} \;
will also do the job
Posted by: Matty on September 7, 2005 04:01 PMUsing zsh, you could just do
rm -rf **/.svn
if your directory structure isn't too huge and your operating system doesn't have ridiculously tiny limits on command line length.
Posted by: Doug L. on September 7, 2005 05:58 PMI use xargs rather than find's -exec argument:
find . -name '.svn' | xargs rm -rf
You can use xargs on any list of file names. For example, to list the contents of files containing the string 'python':
find . | xargs grep -l 'python' | xargs cat
Anyway, you can most assuredly see Perl's TIMTOWTDI heritage in bash...
Posted by: Alan Green on September 8, 2005 05:13 AMOn for a different approach, you could look at "svn export": http://svnbook.red-bean.com/en/1.0/re10.html
I second the zsh tip.
Bash is for wimps.