uniq常见参数
在每行前加上目前出现次数的编号
-c, --count prefix lines by the number of occurrences
仅仅输出重复的行
-d, --repeated only print duplicate lines, one for each group
输出所有重复的行
-D, --all-repeated[=METHOD] print all duplicate lines
groups can be delimited with an empty line
METHOD={none(default),prepend,separate}
比较时跳过前N列
-f, --skip-fields=N avoid comparing the first N fields
–group[=METHOD] show all items, separating groups with an empty line
METHOD={separate(default),prepend,append,both}
比较时,忽略大小写
-i, --ignore-case ignore differences in case when comparing
比较时跳过前N 个字符
-s, --skip-chars=N avoid comparing the first N characters
去除重复的行
-u, --unique only print unique lines
使用’\0’作为行结束符,而不是新换行
-z, --zero-terminated end lines with 0 byte, not newline
对每行第N 个字符以后的内容不作对照
-w, --check-chars=N compare no more than N characters in lines
帮助
–help display this help and exit
版本
–version output version information and exit
例子
[root@hdfa67 txt]# cat word
the day is sunny the the
the sunny is is
[root@hdfa67 txt]# cat word |xargs -n 1
the
day
is
sunny
the
the
the
sunny
is
is
- -c
[root@hdfa67 txt]# cat word |xargs -n 1 | sort | uniq -c
1 day
3 is
2 sunny
4 the
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -c
1 the
1 day
1 is
1 sunny
3 the
1 sunny
2 is
- -d
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -d
the
is
- -D
[root@hdfa67 txt]# cat word |xargs -n 1 | uniq -D
the
the
the
is
is
- -u
[root@hdfa67 txt]# cat word |xargs -n 1
the
day
is
sunny
sunny