< BACK

Bash tips, tricks and code snippets

Copying an array in Bash

According to this posting:

a=(foo bar "foo 1" "bar two")  # create the first array
b=("${a[@]}")                  # copy the first array to a second one 

for n in "${b[@]}" ; do    # to check, print the new array 
    echo "$n" 
done