As we know, in bash programming the way to pass arguments is $1, ..., $N. However, I found it not easy to pass an array as an argument to a functio
$1
$N
This will solve the issue of passing array to function:
#!/bin/bash foo() { string=$1 array=($@) echo "array is ${array[@]}" echo "array is ${array[1]}" return } array=( one two three ) foo ${array[@]} colors=( red green blue ) foo ${colors[@]}