Article View: alt.comp.lang.shell.unix.bourne-bash
Article #10Re: How to expand variables from string?
From: CrispieCritter
Date: Wed, 17 Oct 2007 22:48
Date: Wed, 17 Oct 2007 22:48
30 lines
2238 bytes
2238 bytes
On Oct 17, 1:24 pm, Olivier Langlois <olangl...@sympatico.ca> wrote:
> Hi,
>
> First, sorry if I am cross-posting this question. I am not sure to
> understand the difference between the 2 newsgroups.
>
> 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.
> Here is an example:
>
> var1='$HOME'
> echo $var1
>
> will display $HOME but I would like to find a construction that would
> allow me to print the $HOME value from the var1 variable.
>
> Thank you for your assistance,
> Olivier Langloishttp://www.olivierlanglois.nethttp://blog.olivierlanglois.net
Don't enclose the variable with quotes. For example:
HOME="Some Random Text"
TEST=$HOME
echo $TEST
This would then print the text "Some Random Text" without quotes which
is what you want ?
Glenn
Technical Details
Message-ID:
<1192661300.326198.269000@i38g2000prf.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!i38g2000prf.googlegroups.com!not-for-mailReferences:
<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!i38g2000prf.googlegroups.com!not-for-mail From: CrispieCritter@gmail.com Newsgroups: alt.comp.lang.shell.unix.bourne-bash,gnu.bash Subject: Re: How to expand variables from string? Date: Wed, 17 Oct 2007 15:48:20 -0700 Organization: http://groups.google.com Lines: 31 Message-ID: <1192661300.326198.269000@i38g2000prf.googlegroups.com> References: <1192591475.543957.112000@k35g2000prh.googlegroups.com> NNTP-Posting-Host: 139.130.130.38 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1192661315 18793 127.0.0.1 (17 Oct 2007 22:48:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 17 Oct 2007 22:48:35 +0000 (UTC) In-Reply-To: <1192591475.543957.112000@k35g2000prh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i38g2000prf.googlegroups.com; posting-host=139.130.130.38; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0