This question already has an answer here:
Assume I've got these variables in a bash script:
path_family="/home/family" path_family_log="/var/log/family.log" path_friends="/home/friends" path_friends_log="/var/log/friends.log" path_pets="/home/pets" path_pets_log="/var/log/pets.log"
I want to create a for loop where I could do something like the following:
for TYPE in family friends pets do for FILE in $path_<TYPE> do cat $FILE >> $path_<TYPE>_log done done
Obviously this isn't correct code, just most direct way to express what I want. I'm pulling my hair out trying to figure out how to do the substring substitution on the variable name and have it work as intended.