Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #11239
| From | Jerry Peters <jerry@example.invalid> |
|---|---|
| Newsgroups | comp.os.linux.misc |
| Subject | Re: need bash indirect variable help |
| Date | 2014-06-09 20:44 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <ln56ah$3u2$1@dont-email.me> (permalink) |
| References | <lmvmr3$oqu$1@dont-email.me> <ln2h7e$s1t$1@dont-email.me> <ln2m0f$1og$1@dont-email.me> <87mwdnm2wl.fld@barrow.com> |
Floyd L. Davidson <floyd@apaflo.com> wrote:
> Todd <Todd@invalid.invalid> wrote:
>>On 06/08/2014 01:31 PM, Jerry Peters wrote:
>>>
>>> In bash:
>>> ~$ x=z
>>> ~$ a=x
>>> ~$ echo ${!a}
>>> z
>>>
>>
>>Hi Jerry,
>>
>>Thank you!
>>
>>What exactly does the "!" do?
>
> See the bash man page, under the heading of "Parameter
> Expansion", where the third paragraph down describes it.
> Indirection, or they suggest "indirect expansion", uses
> the contents of a variable as a the variable acted on.
>
> It is the equivalent of the also suggested eval command,
> which might be prefered just because it will be more
> obvious what the eval command is doing while the bang
> operator will be easily missed or confused.
The ${!x} notation has the advantage that you don't have to be as
careful as you do with eval, ie it's harder to sneak in an arbitrary
command if you're in some way processing user input.
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Find similar | Unroll thread
need bash indirect variable help Todd <Todd@invalid.invalid> - 2014-06-07 11:49 -0700
Re: need bash indirect variable help William Unruh <unruh@invalid.ca> - 2014-06-07 23:42 +0000
Re: need bash indirect variable help Eric Pozharski <whynot@pozharski.name> - 2014-06-08 12:19 +0300
Re: need bash indirect variable help Eric Pozharski <whynot@pozharski.name> - 2014-06-09 15:07 +0300
Re: need bash indirect variable help Richard Kettlewell <rjk@greenend.org.uk> - 2014-06-08 09:03 +0100
Re: need bash indirect variable help Todd <Todd@invalid.invalid> - 2014-06-08 02:35 -0700
Re: need bash indirect variable help Huibert Bol <huibert.bol@quicknet.nl> - 2014-06-08 10:29 +0200
Re: need bash indirect variable help Todd <Todd@invalid.invalid> - 2014-06-08 02:36 -0700
Re: need bash indirect variable help Jerry Peters <jerry@example.invalid> - 2014-06-08 20:31 +0000
Re: need bash indirect variable help Todd <Todd@invalid.invalid> - 2014-06-08 14:53 -0700
Re: need bash indirect variable help floyd@apaflo.com (Floyd L. Davidson) - 2014-06-08 14:50 -0800
Re: need bash indirect variable help Jerry Peters <jerry@example.invalid> - 2014-06-09 20:44 +0000
csiph-web