Add double quotation on duplicated name

前端 未结 4 435
南方客
南方客 2021-01-29 06:12

I want to find duplicated name from the file like below and marked them with \"\".

file:

James Miki:123-456-7890
Wang Tai:  234-563-6879
James Miki: 123-         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 06:36

    awk to the rescue!

    $ awk -F: 'a[$1]++ {print "\"" $1 "\"" FS $2}' file
    
    "James Miki": 123-456-7890
    

提交回复
热议问题