This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: xargs problem


* Markus Hoenicka [2007.02.19 10:45]:
> $ echo test1 test2|xargs -t
> /bin/echo test1 test2
> test1 test2
> 
> I'd expect the output to read:
> 
> /bin/echo test1
> test1
> /bin/echo test2
> test2

Your assumption about what xargs does is
incorrect. It does not call the command once for
each argument on its standard input.

Instead, it constructs a command-line, the length
of which is system-dependent. The number of
arguments it will take for each call to the
command isn't clear at all and even depends on the
length of the command itself.

You need to tell xargs explicitly that you want to
take the arguments one by one:

$ echo foo bar | xargs -t -n1
/bin/echo foo 
foo
/bin/echo bar 
bar

-- 
JR

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]