Linux uniq command
Linux uniq command is used to check the ranks and delete text file repeated.
uniq can check the ranks of recurring text file.
grammar
uniq [-cdu][-f<栏位>][-s<字符位置>][-w<字符位置>][--help][--version][输入文件][输出文件]
Parameters:
- The number of rows recurring -c or --count displayed next to each column.
- -d or --repeated display only ranks recurring.
- -f <field> or --skip-fields = <field> Ignore Compares the specified field.
- -s <character position> or --skip-chars = <character position> Ignore the specified character comparison.
- -u or --unique show ranks only once.
- -w <character position> or --check-chars = <character location> Specifies the characters to compare.
- --help displays help.
- --version display version information.
- [Input file] specify the sorted text file.
- [Output file] Specifies the output file.
Examples
Testfile file in line 2, line 5, line 9 of the same behavior, use the uniq command to remove duplicate rows, use the following command:
uniq testfile
testfile The original content:
$ cat testfile #原有内容 test 30 test 30 test 30 Hello 95 Hello 95 Hello 95 Hello 95 Linux 85 Linux 85
After using uniq command to delete duplicate lines, with the following output:
$ uniq testfile #删除重复行后的内容 test 30 Hello 95 Linux 85
Check the file and delete the lines in the file recurring and recurring times the line first line display. Use the following command:
uniq-c testfile
Results output is as follows:
$ uniq-ctestfile #删除重复行后的内容 3 test 30 #前面的数字的意义为该行共出现了3次 4 Hello 95 #前面的数字的意义为该行共出现了4次 2 Linux 85 #前面的数字的意义为该行共出现了2次