Assigning arrays to variables in Bash script seems rather complicated:
a=("a" "b" "c") b=$a echo ${a[0]} echo ${a[1]} echo ${b[0]} echo ${b[1]}
leads to
a b a
instead of
a b a b
Why? How can I fix it?
If you want to copy a variable that holds an array to another name, you do it like this:
a=('a' 'b' 'c') b=( "${a[@]}" )
1.4m articles
1.4m replys
5 comments
57.0k users