Add double quotation on duplicated name

前端 未结 4 395
南方客
南方客 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:51

    Another alternative using sed + sort + uniq pipeline:

    cat file | sed 's/^\(.*\) *: */"\1": /' | sort | uniq -d
    

    The output:

    "James Miki": 123-456-7890
    

提交回复
热议问题