File:
22 Hello
22 Hi
1 What
34 Where
21 is
44 How
44 are
44 you
Desired Output:
22 HelloHi
1 What
34 Where
21 is
44 Howareyou
If there are duplicate values in first field($1) the second field should have appended text
How to achieve this using awk?
Thanks
$ awk '
!seen[$1]++ { keys[++numKeys] = $1 }
{ str[$1] = str[$1] $2 }
END{
for (keyNr=1; keyNr<=numKeys; keyNr++) {
key = keys[keyNr]
print key, str[key]
}
}
' file
22 HelloHi
1 What
34 Where
21 is
44 Howareyou
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With