0

I am trying to append values of different variable

Eg:

p1=100
j=1

and

echo $p1
100
echo $j
1

but I append both the value I need out put as

echo $p$j
100

that means instead of 1, I will give $j which has the same value, is there any other option?

Thanks

jaypal singh
  • 74,723
  • 23
  • 102
  • 147
prabhu
  • 301
  • 2
  • 3
  • 10

1 Answers1

2

You can use ${!var} to refer to the value of the variable var:

$ var="p"$j
$ echo $var
p1
$ echo ${!var}
100
fedorqui
  • 275,237
  • 103
  • 548
  • 598