[comp.unix.misc] xargs

alex@am.sublink.org (Alex Martelli) (03/07/91)

mikel@teda.UUCP (Mikel Lechner) writes:

:ken@csis.dit.csiro.au (Ken Yap) writes:
	...
:>[tucana 462] chmod 644 `find . -type f -print`
:>Too many words from ``.
	...
:A better way to do what you want, (ie one that works), is this command:
:	find . -type f -exec chmod 644 {} ';'
:
:However, this will run a bit slower, since it will create a new chmod
:process for each file encountered.  But, it will work.

Right; an even better one is "find . -type f -print | xargs chmod 644".
If you don't have xargs, I'm sure you can find freely redistributable
implementations without difficulty.  One defect with this is filenames
with newlines, since xargs will take the newline as separator; you
would need -print0 on your find, and xargs0 instead of xargs (or an
equivalent option switch on your xarg).  Not too difficult to hack into
find and xarg free sources, and FSF's GNUfind already has -print0...

-- 
Alex Martelli - (home snailmail:) v. Barontini 27, 40138 Bologna, ITALIA
Email: (work:) martelli@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only), Fidonet: 332/401.3 (home only).

lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (03/15/91)

In article <1991Mar06.215034.639@am.sublink.org> alex@am.sublink.org (Alex Martelli) writes:
: Not too difficult to hack into
: find and xarg free sources, and FSF's GNUfind already has -print0...

So does the find2perl translator.  Seems like a good idea.

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov