I am writing a bash script (for an Open Solaris 11 machine).

I have declared two arrays in the following way:

rpool_fs=(
  "rpool"
  "rpool/ROOT"
  "rpool/ROOT/solaris"
  "rpool/export"
);

shares_fs=(
  "shares"
  "shares/svn"
);

I am able to iterate over the rpool_fs array in the following way:

for i in "${rpool_fs[@]}"
do
  echo $i
done

I would now need to iterate over the union of the rpool_fs and shares_fs arrays. Note that the arrays are disjoint, e.g. I do in fact only need to iterate over a concatention of them. How do I do that?

有帮助吗?

解决方案

Just put one after the other:

for i in "${rpool_fs[@]}" "${shares_fs[@]}"
do
  echo $i
done
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top