去除重复行

第一,用sort+uniq,注意,单纯uniq是不行的。
sort -n test.txt | uniq

第二,用sort+awk命令,注意,单纯awk同样不行,原因同上。

sort -n $file | awk '{if($0!=line)print; line=$0}'

第三,用sort+sed命令,同样需要sort命令先排序。

sort -n $file | sed '$!N; /^ .∗  

Reference:https://blog.csdn.net/ithomer/article/details/6926325?utm_source=copy

猜你喜欢

转载自www.cnblogs.com/anhongyu/p/12977614.html