Another gem similar to the foreach this takes the output for one command and inputs as the arguments to the next command.

eg. cat /tmp/myuserlist | xargs grep /etc/passwd

This would do the same as the foreach command and will search the passwd file for a users listed in a file /tmp/myuserlist.

NB: The " | " is a basic I/O command " | " pipe. This uses output from the previous command as input to the next. 

___________________
 

Another example I used recently was a customer asked for a list of all the zone files in our DNS that included a CNAME to www.somename.com.

eg. find /dns/master -name *.zone | xargs grep www.somename.com. | grep CNAME

Home --> Unix --> Xargs

Xargs