How do I select an array to loop through from an array of arrays?
3
votes
4
answers
3172
views
#!/usr/bin/bash
ARGENT=("Nous devons économiser de l'argent."
"Je dois économiser de l'argent.")
BIENETRE=("Comment vas-tu?" "Tout va bien ?")
aoarrs=("${ARGENT}" "${BIENETRE}")
select arr in "${aoarrs[@]}"; do
for el in "${arr[@]}"; do
echo "$el"
done
break
done
I want this script to print the array names to the user, ARGENT
and BIENETRE
,
so that the user can select one of them. After the user's input the script is meant
to print every element of an array selected. I want to select with select
an array to loop through from an array of arrays (aoarrs
). The reason why I want to use select is because in the real world my array of arrays may have many more than just two arrays in it. How might I accomplish that?
Asked by John Smith
(827 rep)
Aug 28, 2023, 09:10 AM
Last activity: Aug 29, 2023, 05:36 AM
Last activity: Aug 29, 2023, 05:36 AM