Re: bash script question
Good to know. Thank.
On Fri, Apr 18, 2008 at 11:49 AM, Bob McGowan <email@example.com
Others have mentioned the -exec rm... and pipe to xargs rm methods.
I have a simple bash scripting question.
I have a tree of directories from which I would like to recursively dig into, removing source control meta-information from. In this case, the meta-data is in .svn folders.
Does anyone have any elegant suggestions on how to do this?
These are probably the quickest way to do it. There are tools in scripting languages like Perl to accomplish similar things, but that would take more work so is only useful if you need to repeat this several times and want to be extra careful with error checking.
A comment regarding -exec versus piping to xagrs is in order, though.
The -exec will run the command for each instance found. So if there are 3 directories found, rm will be run 3 times.
xargs tries to build up a command with as many arguments as it can fit (at least this is the case in this default use). So with the same 3 directories, you'd get one execution of rm with the three directories as arguments.
For three, this is probably not significant. For hundreds or thousands, it can be a big advantage to avoid all those fork/exec calls.