Is it possible to do something like this?
a=( 1 2 3 )
b=( 4 5 6 )
for num in ( ${a[@]} ${b[@]} ) # or: for num in ${( ${a[@]} ${b[@]} )[@]}
do
echo "$num"
done
# Outputs 1 2 3 4 5 6
I know you can combine them before and then loop through them, but is it possible in only one line?
Current solution:
a=( 1 2 3 )
b=( 4 5 6 )
c=( ${a[@]} ${b[@]} )
for num in ${c[@]}
do
echo "$num"
done
# Outputs 1 2 3 4 5 6
Specify both arrays.
for num in "${a[@]}" "${b[@]}"
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With