문제

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