[root@localhost Linux_Test]# uniq --help 用法:uniq [选项]... [文件] Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output).
With no options, matching lines are merged to the first occurrence.
Mandatory arguments to long options are mandatory for short options too. -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} -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 -s, --skip-chars=N avoid comparing the first N characters -u, --unique only print unique lines -z, --zero-terminated end lines with 0 byte, not newline -w, --check-chars=N 对每行第N 个字符以后的内容不作对照 --help 显示此帮助信息并退出 --version 显示版本信息并退出
若域中为先空字符(通常包括空格以及制表符),然后非空字符,域中字符前的空字符将被跳过。
Note: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'. Also, comparisons honor the rules specified by 'LC_COLLATE'.
[root@localhost uniq]# cat uniq_3.txt a A a b B b B c c c C [root@localhost uniq]# uniq -c uniq_3.txt 1 a 1 A 1 a 1 b 1 B 1 b 1 B 3 c 1 C [root@localhost uniq]# uniq -ci uniq_3.txt 3 a 4 b 4 c [root@localhost uniq]#