xargs

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Joe Toon
Date:  
Subject: xargs
The idea with xargs is to pass it a list of the variable(s) that change
and then tell it what command to run.

This works on FreeBSD, it might be slightly different on your Linux distro:

cat users | xargs -L 1 -I $$ cp /etc/skel/.procmailrc $$

-L 1 tells xargs to pass one user each time it calls the command cp ..
-I $$ tells xargs to substitute $$ in the command for the user

Everything after the first $$ is the command I am running.

To be safe, before doing the actual cp, you will probably want to run
echo to verify that the command lines are correct. You will also want to
make sure that the command line switches are the same on your version of
xargs.

Joe

Craig White wrote:
> I don't ever use the xargs command and unfortunately, my bash book
> doesn't really cover it and it's really tricky.
>
> What I want to do is to distribute some new files which I put into
> /etc/skel to existing users (all users for that matter)...
>
> so I tried...
> ls /home > users # so I can edit list
> cd /home
> cat users > xargs cp /etc/skel/.procmailrc
> ### didn't work
> cp /etc/skel/.procmailrc < xargs users
> cp: overwrite `users'?
> ### clearly didn't work
>
> I've tried a bunch of different things but none seem to be happening...
>
> man xargs is never gonna get through to this thick head