X-Spam-Check-By: sourceware.org
Date: Mon, 19 Feb 2007 11:46:37 -0500
From: Jean-Rene David <jrdavid@magma.ca>
To: cygwin@cygwin.com
Subject: Re: xargs problem
Message-ID: <20070219164637.GB8804@princo>
Mail-Followup-To: cygwin@cygwin.com
References: <1171899485.45d9c45d44ef0@www.domainfactory-webmail.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
In-Reply-To: <1171899485.45d9c45d44ef0@www.domainfactory-webmail.de>
User-Agent: Mutt/1.5.13 (2006-08-11)
X-magma-MailScanner-Information: Magma Mailscanner Service
X-magma-MailScanner: Clean
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

* 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/

