Edmond Rodriguez on 16 Sep 2010 12:38:57 -0700


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

Re: [PLUG] Building a command from variables in BASH

  • From: Edmond Rodriguez <erodrig97.list@gmail.com>
  • To: "Philadelphia Linux User's Group Discussion List" <plug@lists.phillylinux.org>
  • Subject: Re: [PLUG] Building a command from variables in BASH
  • Date: Thu, 16 Sep 2010 15:38:51 -0400
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=3EjBlAQ7UapeWO9l0zYPILHDWssLraKuWBUVa1GElD8=; b=iF12PMzvJpGS1UhJvpKX7Sb/VqKQOrdVVTxn5kXybw2SWFO0/VGXuWHxmgSFbav/ah ODMcn0UXhx6xgpeyVY18QsaZqIuyzq11j9f8jCE6OXGaQ4RU1G35sAEfnk/EB9bteYCi +PjEuYqFDyvqLnaplFi41Mx5/AFpTfzCjdRlE=
  • Reply-to: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
  • Sender: plug-bounces@lists.phillylinux.org

Or eval to try and stay in the same shell?

export B=" | xargs -i echo 'you said {} '"
eval " echo hello $B "

you said hello


On Thu, Sep 16, 2010 at 3:03 PM, Edmond Rodriguez
<erodrig97.list@gmail.com> wrote:
> Here is an example I tried:
>
> export B= " | xargs -i echo 'line was: {}' "
>
> bash -c "echo hello $B"
>
> Results in:  line was: hello
>
>
>
> On Thu, Sep 16, 2010 at 2:46 PM, Isaac Bennetch <bennetch@gmail.com> wrote:
>> Hi,
>>
>> On 9/16/2010 2:40 PM, Michael Bevilacqua wrote:
>> ...
>>>
>>> To test, I do:
>>>
>>> echo $VCIDS
>>>
>>> and I get exactly what I want in the string:
>>>
>>> | sed -e s/ orarcrc01<->cdp1crc02/ 100000 orarcrc01<->cdp1crc02/g | sed
>>> -e s/ sdgdcrc01<->cdc1crc02/ 100001 sdgdcrc01<->cdc1crc02/g | sed -e s/
>>> cindcrc01<->cdc1crc02/ 100002 cindcrc01<->cdc1crc02/g | sed -e s/
>>> akrdcrc01<->cdp1crc02/ 100003 akrdcrc01<->cdp1crc02/g | sed -e s/
>>> daldcrc01<->cdp1crc01/ 100004 daldcrc01<->cdp1crc01/g | sed -e s/
>>> ausrcrc01<->cdc1crc01/ 100005 ausrcrc01<->cdc1crc01/g | sed -e s/
>>> syrrcrc01<->cdc1crc01/ 100006 syrrcrc01<->cdc1crc01/g | sed -e s/
>>> manrcrc01<->cdp1crc01/ 100007 manrcrc01<->cdp1crc01/g | sed -e s/
>>> cdc1crc01<->cdp1crc01/ 100014 cdc1crc01<->cdp1crc01/g | sed -e s/
>>> cdc1crc02<->cdp1crc02/ 100015 cdc1crc02<->cdp1crc02/g
>>>
>>>
>>>
>>> So, now I want to rebuild that original ugly line and execute it, so I do:
>>>
>>> exec "cat $FILE1 $VCIDS > $FILE2"
>>
>> My first thought is:
>> exec "cat $FILE1 `echo $VCIDS` > $FILE2"
>> Or am I over-simplifying the problem?
>> ~isaac
>>
>>> And it fails because $VCIDS is no longer a command, it is now a string,
>>> so cat wants to read it as so.
>>
>> ___________________________________________________________________________
>> Philadelphia Linux Users Group         --        http://www.phillylinux.org
>> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
>> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
>>
>
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug