uniq命令詳解,linux
uniq命令的作用是用來去除文本文件中連續的重複行,中間不能夾雜其他文本行,去除了重複的,保留的都是唯一的,也就是獨特的,唯一的了。
語法:uniq [-cdu][-f<欄位>][-s<字符位置>][-w<字符位置>][--help][--version][輸入文件][輸出文件]
參考例子:
刪除連續文件中連續的重複行:
[root@linux265 ~]# cat testfile
test 30
test 30
test 30
Hello 95
Hello 95
Hello 95
Hello 95
Linux 85
Linux 85
[root@linux265 ~]# uniq testfile
test 30
Hello 95
Linux 85
參數:
-c 打印每行在文本中重複出現的次數
-d 只顯示有重複的紀錄,每個重複紀錄只出現一次
-u 只顯示沒有重複的紀錄