Append column two if line one matches
Append column two if line one matches
(OP)
Sample file:
host1 peach
host1 cherry
host2 pear
host3 apple
host4 orange
host4 banana
host4 plum
Desired output:
host1 peach cherry
host2 pear
host3 apple
host4 orange banana plum
Tried this but can't get it to work.
host1 peach
host1 cherry
host2 pear
host3 apple
host4 orange
host4 banana
host4 plum
Desired output:
host1 peach cherry
host2 pear
host3 apple
host4 orange banana plum
Tried this but can't get it to work.
CODE
awk -F' * *' '{a[$1 " " $2]=a[$1 " " $2] " " $3} END {for (k in a) {print k a[k]}}'
RE: Append column two if line one matches
Why setting a field separator ?
Anyway, the problem is that you seem to count 3 fields, while with or without setting the field separator, you still have only 2 :
CODE
Feherke.
feherke.ga