blob: 43f07e31b4f159da15c9ac0c292a06b661f3c37b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
#
# See ../README.md
#
#
# Run as: bash ch-2.sh < input-file
#
declare -a out
#
# Read in the data, add each field to the appropriate output string
#
IFS=,
while read -a chunks
do for ((i = 0; i < ${#chunks[@]}; i ++))
do out[$i]=${out[$i]}${chunks[$i]},
done
done
#
# Print the output string, dropping the final comma
#
IFS=""
for ((i = 0; i < ${#out[@]}; i ++))
do echo ${out[$i]:0:-1}
done
|