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
  • 71,025
  • 22
  • 98
  • 142
prabhu
  • 171
  • 2
  • 2
  • 9

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
  • 252,262
  • 96
  • 511
  • 570