Reputation: 2463
taking the answer to a previous question, I would like to see if I can refine my code that is simplified below. Is there someway to merge the function of myCorrectVar="${myPrefix}_${mySearch^^}[@]"
into the for i in
line?
#!/bin/sh
myVar_ANIMAL=("fish" "dog" "emu")
myPrefix="myVar"
mySuffix="animal"
mySearch="${mySuffix}"
myCorrectVar="${myPrefix}_${mySearch^^}[@]"
for i in "${!myCorrectVar}"
do
echo "animal = $i"
done
gives output as expected
animal = fish
animal = dog
animal = emu
Upvotes: 0
Views: 23