In general, you should strive to always process each variable in a quoted form (for example, "${ignore[@]}" ) instead of trying to insert quotes yourself (just like you should use parameterized instructions instead of escaping the input in SQL) because it is difficult to be perfect by manually escaping; for example, suppose a variable contains a quotation mark.
In this regard, I would like to create an array where each argument word for find becomes an element: ("-o" "-path" "$dir/archive" "-prune" "-o" "-path" "$dir/crl" "-prune" "-o" "-path" "$dir/cfg" "-prune") (12-element array).
Unfortunately, Bash does not seem to support a parameter expansion form, where each element expands to a few words. ( p{1,2,3}q expands to p1q p2q p3q , but with a=(1 2 3) , p"${a[@]}"q expands to p1 2 3q .) So you need to refer to the loop :
declare -a args=() for i in "${ignore[@]}" do args+=(-o -path "$dir/$i" -prune)
source share