On 30/07/02 at 18:40 Simon Huggins wrote:
>On Tue, Jul 30, 2002 at 09:16:15AM +0100, Graeme Fowler wrote:
>> ...and (this may vary from distro to distro) Paul missed the "-i" and
>"{}"
>> from xargs, too:
>
>Hmm, does yours need that then? Strange.
Putting the -i and {} in makes no difference to me (on Cygwin) if a file to
remove exists, but avoids a seemingly harmless attempt at rm and associated
error message if no file matches the pattern.
>
>Whilst we're on the subject of find and xargs the most useful flags to
>each are to add -print0 to your find and -0 to your xargs so that
>filenames with spaces or bizarre characters can be treated.
>
Thanks for all the replies everyone. It seems I've got:
find ./ -name '*.o' -print0 | xargs -0t -i rm {}
or
find ./ -name '*.o' -exec rm -f {} \;
which both work nicely. I can certainly appreciate the potential power of
the approach above (I can see that work avoidance this week is going to
involve trying to remove files based on the output of grep - and no, don't
tell me please!) but I'm still curious as to why
rm -rf *.o
doesn't simply delete all instances of the pattern recursively from the
current directory. Given that rm can delete a whole directory tree
recursively, and can delete non-recursively to a pattern, it would seem an
almost trivial addition. Is there a good reason for not doing this that
I'm missing, or is it just the way things are?
Cheers - Dave
--------------------------------------------------------------------
http://www.lug.org.uk http://www.linuxportal.co.uk
http://www.linuxjob.co.uk http://www.linuxshop.co.uk
--------------------------------------------------------------------
This archive was generated by hypermail 2.1.3 : Tue 30 Jul 2002 - 20:22:34 BST