On Fri, 25 Jun 2004, Michael Havens wrote:
> 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?
It is very similar to that `backtick` command you learned recently.
xargs reads the standard input and then runs a command by putting the
lines read as the new command's command-line arguments.
I often use it to put multiple lines on one line (since it removes the
newlines) instead of using fmt.
By default xargs does echo.
rainier:~/work/invoices$ echo 1 2 3 | xargs
1 2 3
rainier:~/work/invoices$ echo 1 2 3 | xargs echo
1 2 3
Also:
echo `ls`
is similar to
ls | xargs
Have fun ...
Jeremy C. Reed
BSD News, BSD tutorials, BSD links
http://www.bsdnewsletter.com/
---------------------------------------------------
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