I'm trying to take elements from $Table_Header_Labels in a loop and have it grab the string of the same name to be used for string length. Ex: Grabbed "Apple" from the array and then convert it to grab $Apple to get the string to do ${#Apple}.
#!/bin/bash
# Create Array
declare -a Array=('Red' 'Blue' 'White');
# Set Variable
Red="Apples are Red!"
# Get Size of Variable from Array Element
for i in ${Array[0]}
do
Element=${i}
Element_Size="${i}_Size"
# Print the generated one
echo "$Element_Size = ${#Element}"
# Print correct one to compare
echo "Red_Size = ${#Red}"
echo ""
done
Please take note I purposely made it so the loop only goes once. Currently, the Red_Size counts the array element itself which is three. I'm trying to get it to take the array element and grab the string assigned to the variable that is replicated by the array element.
Basic break down explanation: Apple => $Apple
Is this even possible with BASH?