2013-08-19 シェルで配列 配列と配列をjoinする #!/bin/bash last_id=1 while IFS=" ", read a b do echo "$a - $b" if [ $a -ne $last_id ] then str="$(IFS=,; echo "${arr[*]}")" echo $str arr=() fi arr=("${arr[@]}" "$b") last_id=$a done str="$(IFS=,; echo "${arr[*]}")" echo $str