-c, --count 在每行前加上表示相应行目出现次数的前缀编号
-d, --repeated 只输出重复的行
-D, --all-repeated[=delimit-method 显示所有重复的行
delimit-method={none(default),prepend,separate}
以空行为界限
-f, --skip-fields=N 比较时跳过前N 列
-i, --ignore-case 在比较的时候不区分大小写
-s, --skip-chars=N 比较时跳过前N 个字符
-u, --unique 只显示唯一的行
-z, --zero-terminated 使用'\0'作为行结束符,而不是新换行
-w, --check-chars=N 对每行第N 个字符以后的内容不作对照
--help 显示此帮助信息并退出
--version 显示版本信息并退出
若域中为先空字符(通常包括空格以及制表符),然后非空字符,域中字符前的空字符将被跳过。
提示:uniq 不会检查重复的行,除非它们是相邻的行。
如果您想先对输入排序,使用没有uniq 的"sort -u"。
$ cat testfile #原有内容
test 30
test 30
test 30
Hello 95
Hello 95
Hello 95
Hello 95
Linux 85
Linux 85
统计各行在文件中出现的次数:
$ sort testfile1 | uniq -c
3 Hello 95
3 Linux 85
3 test 30
在文件中找出重复的行:
$ sort testfile1 | uniq -d
Hello 95
Linux 85
test 30
只显示出现一次的行
1
cat last.txt |uniq -u