Uniq

来自WordPress中文文档
跳转至: 导航搜索

Linux命令:uniq

功能说明:检查及删除文本文件中重复出现的行列。
语  法:uniq [-cdu][-f<栏位>][-s<字符位置>][-w<字符位置>][--help][--version][输入文件][输出文件]
补充说明:uniq可检查文本文件中重复出现的行列。
参  数:
 -c或--count   在每列旁边显示该行重复出现的次数。
 -d或--repeated   仅显示重复出现的行列。
 -f<栏位>或--skip-fields=<栏位>   忽略比较指定的栏位。
 -s<字符位置>或--skip-chars=<字符位置>   忽略比较指定的字符。
 -u或--unique   仅显示出一次的行列。
 -w<字符位置>或--check-chars=<字符位置>   指定要比较的字符。
 --help   显示帮助。
 --version   显示版本信息。
 [输入文件]   指定已排序好的文本文件。
 [输出文件]   指定输出的文件。 


英文版本,欢迎翻译:

ABOUT UNIQ

Report or filter out repeated lines in a file.

SYNTAX

uniq [-c | -d | -u ] [ -f fields ] [ -s char ] [-n] [+m] [input_file [ output_file ] ]

-c Precede each output line with a count of the number of times the line occurred in the input. -d Suppress the writing of lines that are not repeated in the input. -u Suppress the writing of lines that are repeated in the input. -f fields Ignore the first fields fields on each input line when doing comparisons, where fields is a positive decimal integer. A field is the maximal string matched by the basic regular expression: blank:*[^[:blank:]]*

If fields specifies more fields than appear on an input line, a null string will be used for comparison.

-s char Ignore the first chars characters when doing comparisons, where chars is a positive decimal integer. If specified in conjunction with the -f option, the first chars characters after the first fields fields will be ignored. If chars specifies more characters than remain on an input line, a null string will be used for comparison. -n Equivalent to -f fields with fields set to n. +m Equivalent to -s chars with chars set to m. input_file A path name of the input file. If input_file is not specified, or if the input_file is -, the standard input will be used. output_file A path name of the output file. If output_file is not specified, the standard output will be used. The results are unspecified if the file named by output_file is the file named by input_file.

EXAMPLES

uniq myfile1.txt > myfile2.txt - Removes duplicate lines in the first file1.txt and outputs the results to the second file.