On 03/09/2017 10:05 PM, Adam Carter wrote:
> I have one command that dumps out a number of lines of output, and i want
> to have another command run multiple times taking a single line contents as
> its argument(s) each time. From what i understand of xargs it takes all the
> piped input and runs a command once with each of the piped inputs as
> another argument.
> 
> Eg. say i want to run ethtool against each active interface dumped out by;
> ifconfig | grep ^[a-zA-Z] | awk '{print $1}'
> 
> Tnx
> 

You can still use xargs to do this, you just need to pass "-n 1" to tell
xargs to only use 1 argument from the input per command run (instead of
as many as possible), like so:

ifconfig | grep [^A-Za-z] | awk '{print $1}' | xargs -n 1 ethtool

-- 
Jonathan Callen

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to