Substitution within substitution- Is it possible?

Substitution within substitution- Is it possible?

Post by Paul Porcel » Sat, 09 Sep 1995 04:00:00



I have two  variables
jbc3=8
i=3

i now have the following loop

for i in 3
do
  echo $jbc$i
done

What i actually want to print is the value 8.
i.e. substutute the $i for 3 , then evaluate $jbc3.
Is there some way to combine these two substitutions.

Thanks in advance.
--
Paul Porcelli
Dept of Aerospace Engineering
University of Glasgow

 
 
 

Substitution within substitution- Is it possible?

Post by Andreas Schw » Sat, 09 Sep 1995 04:00:00



|> I have two  variables
|> jbc3=8
|> i=3

|> i now have the following loop

|> for i in 3
|> do
|>   echo $jbc$i
|> done

|> What i actually want to print is the value 8.
|> i.e. substutute the $i for 3 , then evaluate $jbc3.
|> Is there some way to combine these two substitutions.

eval echo \$jbc$i
--
Andreas Schwab                                      "And now for something


 
 
 

Substitution within substitution- Is it possible?

Post by Zefr » Sun, 10 Sep 1995 04:00:00



>I have two  variables
>jbc3=8
>i=3

>for i in 3
>do
>  echo $jbc$i
>done

jbc3=8
for i in 3; do
  eval echo \$jbc$i
done

-zefram

 
 
 

1. Command Substitution within Parameter Substitution?

Hi,

(GNU bash, version 2.05b.0(1)-release (i586-mandrake-linux-gnu).)

Is it possible, in the above version of BASH, to have (a) command
substitution(s) within (a) parameter substitution(s)?  I tried the
following in a BASH script:

gqview ${$( cat $HOME/mydisplay_return )#*\ }

and it didn't work.  The above code line was to execute GQview (an image
viewer) with the name of an image file that was stored, on it's own, in a
file called 'mydisplay_return', hence the 'cat' command to get at the image
file name.  The file name stored in the 'mydisplay_return' file was
prefixed with an identifying number followed by a space, hence the '#*\ '
parameter substitution to just leave the file name.  But it doesn't work.
What's wrong?

Yours,
Gary Hayward.

2. automating a telnet...<ARRGH>.

3. parameter substitution within backquotes

4. dtpad and umask

5. Variable substitution within a variable name

6. driver for Intel740

7. Help:is single character substitution with mod_rewrite possible ?

8. Q: setup printer!!!

9. Substitution Variables

10. bash history substitution

11. Filename Substitution question

12. Variable substitution in a shell script

13. Alias substitution