AIXSolarisAdmin
MIS
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]}}'