How to delete duplicated rows based in a column value?

后端 未结 4 2031
囚心锁ツ
囚心锁ツ 2021-01-05 06:03

Given the following table

 123456.451 entered-auto_attendant
 123456.451 duration:76 real:76
 139651.526 entered-auto_attendant
 139651.526 duration:62 real:         


        
4条回答
  •  梦毁少年i
    2021-01-05 06:44

    you didn't give an expected output, does this work for you?

     awk '!a[$1]++' file
    

    with your data, the output is:

    123456.451 entered-auto_attendant
    139651.526 entered-auto_attendant
    139382.537 entered-auto_attendant
    

    and this line prints only unique column1 line:

     awk '{a[$1]++;b[$1]=$0}END{for(x in a)if(a[x]==1)print b[x]}' file
    

    output:

    139382.537 entered-auto_attendant
    

提交回复
热议问题