I'd like to use variables inside the for loop in shell.
My current code:
VAA="1st_first"
VAB="2nd_second"
VAC="3rd_third"
for i in VAA VAB VAC; do
if [[ "${i}" =~ ^[A-Za-z]*$ ]]; then
echo "$i variable is a word"
else
echo "$i variable is not a word"
fi
done
The expected result would be checking the $VAR1, $VAR2, and $VAR3 variables, then print that it's a word.
The current output is:
VAA variable is a word
VAB variable is a word
VAC variable is a word
It's not correct, because the "$VAA" is contains a number.
How can I use variables from outside of for loop?
for i in "$VAA" "$VAB" "$VAC"; do
– muru Dec 01 '22 at 10:46