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 wrote:

> maybe I'm being dense, but xargs does not seem to do what it should:
>
> $ 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
>
> What am I doing wrong?

Your expectation is wrong. xargs will - by default - not start a seperate 
instance of the to-be-executed process for each of the arguments it reads 
from stdin, but instead it gathers some and feeds them to the process at 
once.
You can limit the number or args each sub-process will be fed with -n 
or --max-args. I. e.
echo test1 test2|xargs -t -n 1
should do what you expect.

BTW: this is not Cygwin-specific.

Regards
  mks

--
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]