技术员联盟提供win764位系统下载,win10,win7,xp,装机纯净版,64位旗舰版,绿色软件,免费软件下载基地!

当前位置:主页 > 教程 > 服务器类 >

Linux删除重复行的代码

来源:技术员联盟┆发布时间:2017-04-26 00:23┆点击:

注意,单纯uniq是不行的,注意。

下面是三种方法 第一,单纯awk同样不行。

用sort+sed命令,用sort+uniq, sort -n $file | awk '{if($0!=line)print; line=$0}' 第三。

sort -n $file | sed '$!N; /^.n1$/!P; D' Shell脚本 ? 1 2 3 4 5 6 # !/bin/sh file='test.txt' sort -n $file | uniq sort -n $file | awk '{if($0!=line)print; line=$0}' sort -n $file | sed '$!N; /^(.*)n1$/!P; D' 测试文件: yanggang@barry$ cat test.txt aaa bbbbb ccccc 123 aaaaa 123 bbb aaa 执行结果: yanggang@barry$ ./diffRow.sh aaa aaaaa bbb bbbbb ccccc 123 服务器教程平板电脑教程视频播放教程 ,原因同上,经常要删除重复行,同样需要sort命令先排序,用sort+awk命令, Linux删除重复行的代码 文本处理时, ? 1 sort -n test.txt | uniq 第二,。