Reputation: 9807
Let's suppose I have following two variables:
arg1=5
count5="test"
Now, I want to able to do something like:
echo ${'count' . $arg1} #which should give me "test" but its returning bad-substitution error
i.e. can part of a variable can be set as variable in bash?
Upvotes: 1
Views: 85
Reputation: 9807
Okay, got it working via indirect variable reference introduced in Bash v2 as:
my_var="count$arg1"
echo ${!my_var}
Upvotes: 2