Key Matching using shell

前端 未结 2 1051
萌比男神i
萌比男神i 2020-12-22 12:44

I wanted to see different type of answers I receive from you guys for the below problem. I am curious to see below problem being solved completely through array or any other

2条回答
  •  情书的邮戳
    2020-12-22 13:26

    Try this:

    awk -F', ' '{a[$1]=a[$1]","$2}END{for(i in a) print i a[i]}' input.txt
    

    Output:

    Name1,Phone1,Phone2
    Name2,Phone2,Phone1
    Name3,Phone1
    Name4,Phone5,Phone1
    

提交回复
热议问题