[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xargs - how to get it to execute input args as "the command"?

From: James Youngman
Subject: Re: xargs - how to get it to execute input args as "the command"?
Date: Sun, 5 Jan 2014 13:41:13 +0000

On Sun, Jan 5, 2014 at 11:09 AM, Linda A. Walsh <address@hidden> wrote:
> James Youngman wrote:
>> You can use the "sh -c" trick to run the first argument as the command.
> ----
> Do you think the above case could be optimized?  As I mentioned in my inital
> query, I wanted to avoid shell overhead on 80 thousand sub-jobs.

You have 80,000 lines (=80k commands to run from xargs) or 80,000
command-line srguments?   If the latter, how many commands?

> I.e. is there any reason xargs couldn't run the arguments directly -- i.e.
> taking the first word of input as a program to run and either do a path
> lookup, OR require an absolute path (either would be fine)

I'm reluctant for the usual reasons
1. I think thjs is a niche use case
2. It imposes documentation, testing and maintenance effort out of
proportion (ass far as I can see at the moment, though I am willing to
change my mind) to its usefulness

Plus another reason:
3. The usual execution model of xargs is to run a trusted command on
potentially untrusted arguments.   This widens the exposure somewhat,
because the command being run may also not be trusted.

>> You can use -d to select the delimiter.
> ----
> That will work.. didn't see it would override the normal quote
> processing...  Thanks!

If the documentation isn't clear I should fix it.   If you'd like to
suggest a specific change (to both the manual page and the Texinfo
documentation) that would be useful.

> I looked at 'parallel' and 'sem' as well, and they want a command on
> the command line as well... geez...  you'd think something would
> take a list of command in a file and run them in parallel (subject
> to load constraints) w/o having to run a shell w/each command.

batch(1) does this (though you would need to split the input and it
probably uses a shell to launch the command).

> Hard to believe such a simple thing wouldn't be an option...but
> is there any  reason why putting a "-I {}" by itself on the command
> line shouldn't work?

If you specify zero initial arguments, the default is "echo".

> (tried "exec", but I guess that is a shell builtin...sigh)...

This email is intended solely for the use of its addressee, sender,
and any readers of a mailing list archive in which it happens to
appear.   If you have received this email in error, please say or type
three times, "I believe in the utility of email disclaimers," and then
reply to the author correcting any spellings (and, optionally, any
incorrect spellings), accompanying these with humorous jests about the
author's parentage.   If you are not the addressee, you are
nevertheless permitted to both copy and forward this email since
without such permissions email systems are unable to transmit email to
anybody, intended recipient or not.  To those still reading by this
point, the author would like to apologise for being unable to maintain
a consistent level of humour throughout this disclaimer.  Contents may
settle during transit.  Do not feed the animals.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]