[Top][All Lists]

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

Re: xargs bugs

From: Eric Blake
Subject: Re: xargs bugs
Date: Fri, 01 Nov 2013 08:26:02 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0

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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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