I have a lot of predefined variables in bash script, like
$adr1="address"
$out1="first output"
$adr2="another address"
$out2="second output"
and number is taken from external source, so for example if number is 1 I like to have variable $adr to be value from $adr1 and $out to be from $out1. If number is 2 $adr should be value of $adr2 and $out should be value from $out2 etc.
Edit 27.01.2020: OK, maybe I was not clear enough, will try again with example:
#! /bin/bash
adr1="address"
out1="first-output"
adr2="another-address"
out2="second-output"
if [ $1 -eq 1 ]; then
adr=$adr1
out=$out1
elif [ $1 -eq 2 ]; then
adr=$adr2
out=$out2
fi
echo "adr=$adr, out=$out"
Now I will run script (lets say it is named test.sh):
./test.sh 1
adr=address, out=first-output
And another run:
./test.sh 2
adr=another-address, out=second-output
I would like to eliminate this if - elif statement because later there will be also adr3 and out3 and adr4 and out4 etc.