🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.shell.unix.bourne-bash
Article #13

Re: How to expand variables from string?

#13
From: William Pursell
Date: Mon, 29 Oct 2007 05:57
23 lines
2077 bytes
On 17 Oct, 03:24, Olivier Langlois <olangl...@sympatico.ca> wrote:
>
> First, sorry if I am cross-posting this question. I am not sure to
> understand the difference between the 2 newsgroups.

Unaware of the existence of alt.comp.lang.shell.unix.bourne-bash,
I am grateful to you for exposing me to it.  (Or it to me, rather.)

> My problem is that I have a shell variable containing a string
> composed of variable names preceded with the expension operator ('$')
> and I am fighting with the shell to find a way to make the expension.

eval is your friend:

$ FOO="foo's text"
$ BAR='$FOO'
$ echo $BAR
$FOO
$ eval echo $BAR
foo's text

(Perhaps I should have used a character other than '$' for my
prompt...)
Technical Details
Message-ID: <1193637442.499294.258680@o80g2000hse.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!o80g2000hse.googlegroups.com!not-for-mail
References: <1192591475.543957.112000@k35g2000prh.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114230,e6e9ec2e0724a623
X-Google-Thread: 1054c0,e6e9ec2e0724a623
X-Google-Attributes: gid114230,gid1054c0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!o80g2000hse.googlegroups.com!not-for-mail
From:  William Pursell <bill.pursell@gmail.com>
Newsgroups: alt.comp.lang.shell.unix.bourne-bash,gnu.bash
Subject: Re: How to expand variables from string?
Date: Sun, 28 Oct 2007 22:57:22 -0700
Organization: http://groups.google.com
Lines: 24
Message-ID: <1193637442.499294.258680@o80g2000hse.googlegroups.com>
References: <1192591475.543957.112000@k35g2000prh.googlegroups.com>
NNTP-Posting-Host: 90.206.19.36
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1193637442 20021 127.0.0.1 (29 Oct 2007 05:57:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 29 Oct 2007 05:57:22 +0000 (UTC)
In-Reply-To: <1192591475.543957.112000@k35g2000prh.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: o80g2000hse.googlegroups.com; posting-host=90.206.19.36;
   posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0