Say I have two variables;
var_one_string=foo
var_two_string=bar
How would I accomplish something like this (pseudo code examples);
EXAMPLE 1
for i in one two; do
echo $var_${i}_string
done
# Desired output
foo
bar
EXAMPLE 2
for i in one two; do
echo $var_$(echo ${i})_string
done
# Desired output
foo
bar
I understand that this is bad substitution, I am just wondering if there is a way to nest a string within another variable call?
EDIT: I was able to get it to work
var_one_string=foo
var_two_string=bar
for i in $(echo ${!var_*}); do
echo ${!i}
done
foo
bar