[GLLUG] Merging Records in Input

Steve Parker steve at steve-parker.org
Thu Dec 5 23:26:21 UTC 2013


On 05/12/13 22:38, Mick Farmer wrote:
> Dear GLLUGers,
>
> I have an input consisting of two fields such as
>
>
I thought join, cmp or paste should do it, though this bash script will:

$ cat mick.sh
#!/bin/bash
declare -a mick

while read index value
do
   mick[$index]="${mick[$index]} $value"
done < mick.txt

for x in ${!mick[@]}
do
   echo "$x  ${mick[$x]}"
done


$ ./mick.sh
7   010c 060b
8   003d 003g 005n 008c 010a
9   100c
11   005m 013a
steve at pantera:/tmp$





More information about the GLLUG mailing list