[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: xargs bugs

From: Xiao Wu DAI
Subject: RE: xargs bugs
Date: Mon, 4 Nov 2013 10:10:41 +0800


 Many thanks for your quite detailed explanation.
It's not bug but my limit knowledge.
 It works and I have learned the  details from you.


Best Regards
 Xiaowu Dai

(+)86 –(0)755-8601-2139
Tina: 097-2139


-----Original Message-----
From: Eric Blake [mailto:address@hidden 
Sent: Friday, November 01, 2013 10:26 PM
To: Xiao Wu DAI; address@hidden
Subject: Re: xargs bugs

On 11/01/2013 01:54 AM, Xiao Wu DAI wrote:
> hi,
> it seems `echo ..` doesn't work in GNU xargs version 4.2.27 like below
> | xargs -t -i mv {}`echo {} |sed 's/mode/dai/g'`

'echo' is your friend.  Try:

echo xargs -t -i mv {} `echo {} | sed 's/mode/dai/g'`

to see that you were executing:

xargs -t -i mv {} {}

which is NOT what you wanted.  You need to use proper quoting; and since you 
want to do programmatic shell actions on {}, you need your xargs to spawn an 
instance of sh.  Try:

xargs -t -i sh -c 'mv "$1" "$(echo "$1" | sed 's/mode/dai/g')"' sh {}

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]