Reputation: 165
I'm trying to make a shell script but I'm stuck.
This doesn't work and I don't know why.
a=( "1" "2" )
b=( "3" "4" )
c=( "$a" "$b" )
for d in "${c[@]}"; do
echo "${d[1]}"
done
Upvotes: 1
Views: 88
Reputation: 88583
With bash:
a=( "1" "2" )
b=( "3" "4" )
# concatenate array a and b to new array c
c=( "${a[@]}" "${b[@]}" )
for d in "${c[@]}"; do
echo "$d"
done
Output:
1 2 3 4
Upvotes: 2