[comp.unix.ultrix] xargs bug in 3.0

john@compugen. (John Beaudin) (08/11/89)

I couldn't get the following to work from a cmd line in either the
sh or csh:

ls | xargs -i -t echo {} testing

All that happened was the line 'echo {} testing' printed once for
every filename generated. Phoned Software Support; they confirmed the
bug. Oh well, have to script it I suppose.

-- 
We don' sign no stinkin dots

grr@cbmvax.UUCP (George Robbins) (08/13/89)

In article <2072@compugen.> john@compugen. (John Beaudin) writes:
> I couldn't get the following to work from a cmd line in either the
> sh or csh:
> 
> ls | xargs -i -t echo {} testing
> 
> All that happened was the line 'echo {} testing' printed once for
> every filename generated. Phoned Software Support; they confirmed the
> bug. Oh well, have to script it I suppose.

Ya get them to file an SPR?

It does seem quite broken, also the manual pages seem to say that the
default "replstr" is {|} while the System V manual pages specify the
more obvious {} token.  None of these work, nor does a simple -ix
substitution which would rule out "improvments" by the shell command
line interpretation.

Note that xargs(1) is a wretched System V kludge 8-), the same kind of
thing can be handlded in a very general manner by a pipeline consisiting
of <file name generator> | <command generator> | <shell> as in:

ls | sed -e 's/.*/echo & testing/' | sh

Substitution of find(1) for ls, gives you a fair amount file selection
capability, and while sed(1) can do most things under the sun, awk(1)
or other filters, or more than one filter, can often be used to advantage.

This method can also be used for tasks beyond the rather simplistic
capabilites of xargs, such as generating rename or other commands where
the arguments might be multiple functions of the input filenames.

Some people also use short c-shell or bourne shell loops entered at the
command line, however I find that history editing lets on use the
find/sed/sh style with much less retyping...

-- 
George Robbins - now working for,	uucp: {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@uunet.uu.net
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)