delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/02/19/11:34:58

X-Spam-Check-By: sourceware.org
From: Markus =?iso-8859-1?q?Sch=F6nhaber?= <mailing-cygwin AT schoenhaber DOT de>
Reply-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: xargs problem
Date: Mon, 19 Feb 2007 17:34:16 +0100
User-Agent: KMail/1.9.6
References: <1171899485 DOT 45d9c45d44ef0 AT www DOT domainfactory-webmail DOT de>
In-Reply-To: <1171899485.45d9c45d44ef0@www.domainfactory-webmail.de>
MIME-Version: 1.0
Message-Id: <200702191734.17079.mailing-cygwin@schoenhaber.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019