1

suppose two variables: A1=1234 A2=5678

for i in 1 2
do
echo $A$i
done

it prints:

1
2

i want to print:

1234
5678

how to do that?

User_890
  • 169
  • 1
  • 9
  • Try : https://stackoverflow.com/questions/1921279/how-to-get-a-variable-value-if-variable-name-is-stored-as-string?answertab=votes#tab-top – sat Aug 24 '17 at 07:25

1 Answers1

0

You need:

for i in 1 2
do
  temp="A$i"
  echo "${!temp}"
done
GhostCat
  • 137,827
  • 25
  • 176
  • 248