Can U pipe filenames to rm???

Matthew Farwell dylan at ibmpcug.co.uk
Sat Oct 6 02:30:50 AEST 1990


In article <941 at hls0.hls.oz> george at hls0.hls.oz (George Turczynski) writes:
>From previous postings-
>
>> >Example:
>> >  find {{stuff here}} -print | xargs rm -f
>  
>> Locally, we've hacked our "find" to handle:
>> 	$ find . -name \*.old -rm
>
>Our `find' (SunOS) supports the `-exec' option, and I assume this would be
>fairly common.  So, those of you without xargs, and who | a. can't,  b. don't
>want to | hack `find' use it like this:
>
>	find {{stuff here}} -exec rm -f {} \;
>
>Why use `xargs' when you don't need to ?

2 points.
1) The original posting wasn't about find, it was about another pipe which
produced filenames on stdout, so comments on xargs were required.

2) find / -exec rm -f {} \; spawns rm everytime it encounters a file
so its very slow and expensive, whereas xargs collects all the filenames
together, bundles them up into lines which won't exceed the system limit
and then spawns one job for all of those. Its much more environmentally
friendly.

Dylan.
-- 
Matthew J Farwell                 | Email: dylan at ibmpcug.co.uk
The IBM PC User Group, PO Box 360,|        ...!uunet!ukc!ibmpcug!dylan
Harrow HA1 4LQ England            | CONNECT - Usenet Access in the UK!!
Phone: +44 81-863-1191            | Sun? Don't they make coffee machines?



More information about the Comp.unix.shell mailing list