first of all, i've read the question for loop with multiple conditions in Bash scripting but it does not work for what i intend to do. In the following script, a first for loop assign f quantity of arrays to a pair of variables (CON_PERC and CON_NAME)
f=0
for i in "${container[@]}"; do
CON_PERC[$f]=$(awk '{print int($2+0)}' <<< ="${container[$f]}") #CON_PERC[0] = 2; CON_PERC[1] = 0
CON_NAME[$f]=$(awk '{print $1}' <<< "${container[$f]}") #CON_NAME[0] = hi; CON_NAME[1] = bye
((f++))
done
what i need to do now, is in a separate loop, check every array of both variables and print themm. what would be the best way to do it?
what i tough is something like this
e=0
for ((x in "$CON_PERC[@]" && z in "$CON_NAME[@]")); do
echo "${CON_NAME[$e]} ${CON_PERC[$e]}"
((e++))
done
but it seems that for ((i in "$CON_PERC[@]" && e in "$CON_NAME[@]")) isnt valid in bash.
The question is, what is the best way to approach this, should i exclusively use a nested loop or is other way around it?