On Fri, Jun 25, 2004 at 06:18:04PM +0000, Michael Havens wrote:
> I am going through this ebook and come to some lines:
>
> find / -uid 9 -print > /tmp/uid.9
> cat /tmp/uid.9 | xargs chown news
>
> Which I think is telling the macine:
>
> search entire box for a file with a user id set to 9 and then to put the
> output into a file called /tmp/uid.9
>
> then
>
> feed the output of cat into chown
>
> I have two questions about this:
> 1- Is my guess after reading the man pages correct?
Yes.
> 2- What is the use of xargs?
I hope you have done "man xargs" and studied the results
It invokes its arguments as a command and inital arguments with extra
arguments for the command are taken from the standard input.
For example if file foo contains three lines:
larry
moe
curly
and you do:
xargs echo hello there <foo
xargs will execute the command:
echo hello there larry moe curly
When you use find with xargs, you can run into trouble if any
of the filenames contain whitespace. I would have written the
sample command above as:
find / -uid 9 -print0 | xargs -0 chown news
-print0 causes find to separate its output with nul (0) characters
instead of newlines. -0 tells xargs that it's input is separated
by nuls instead of whitespace.
-Dale Farnsworth
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss