How to delete duplicate lines in a file without sorting it in Unix?

后端 未结 9 1614
Happy的楠姐
Happy的楠姐 2020-11-22 17:26

Is there a way to delete duplicate lines in a file in Unix?

I can do it with sort -u and uniq commands, but I want to use sed

9条回答
  •  长发绾君心
    2020-11-22 17:55

    This can be achieved using awk
    Below Line will display unique Values

    awk file_name | uniq
    

    You can output these unique values to a new file

    awk file_name | uniq > uniq_file_name
    

    new file uniq_file_name will contain only Unique values, no duplicates

提交回复
热议问题