[Discuss] GNU xargs trick

Mike Small smallm at sdf.org
Wed Apr 27 14:26:52 EDT 2016


Rich Pieri <richard.pieri at gmail.com> writes:

> On 4/27/2016 12:31 PM, Mike Small wrote:
>> New line characters in particular. -I changes matters to line at a
>> time so other space characters should be okay, right?
>
> Yes, line at a time, but you may need to quote the substitution string
> in the command arguments.

I wondered about that but when I tried a little experiment it seemed
like it's probably not necessary. When I "cat | xargs -I{} ls {}" and
type some two word lines the files ls complains of being missing do seem
to be the two word "files" I'm typing. Seems like maybe what xargs gets
(i.e. the expansion of {}) goes right to one of the exec library calls
without further shell intervention. Let me know if I'm wrong on this. I
continue to find the various Unix shell expansions too complicated to
keep in my head at once or retain over time. And unfortunately I'm not
getting any smarter as I age.

On this topic, the debian bug report where GNU Parallels came into being
as a debian package has some interesting discussion re. GNU parallel and
xargs and another thing called parallel from moreutils. Early in the
discussion there's the question of what parallel can do that xargs
cannot:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518696

-- 
Mike Small
smallm at sdf.org



More information about the Discuss mailing list