Linux Common basic commands: uniq-to repeat

Source: Internet
Author: User

Uniq command

Function: Outputs or ignores duplicate rows in a file

Format: uniq [option] [File|stdin]

[Email protected]:~/linux/Uniq$CatGhostwu.txt192.168.1.2192.168.1.8192.168.1.3192.168.1.3192.168.1.9192.168.1.8192.168.1.8192.168.1.0192.168.1.3[email protected]:~/linux/Uniq$UniqGhostwu.txt192.168.1.2192.168.1.8192.168.1.3192.168.1.9192.168.1.8192.168.1.0192.168.1.3

A continuous repeating row is removed. If you want to keep only the unique file, you can use the option-u

[Email protected]:~/linux/uniquniq -192.168. 1.2 192.168. 1.8 192.168. 1.9 192.168. 1.0 192.168. 1.3

-C: To repeat and calculate the number of occurrences per row

[Email protected]:~/linux/Uniq$Uniq-C Ghostwu.txt1 192.168.1.2      1 192.168.1.8      2 192.168.1.3      1 192.168.1.9      2 192.168.1.8      1 192.168.1.0      1 192.168.1.3[email protected]:~/linux/Uniq$Cat-N ghostwu.txt1    192.168.1.2     2    192.168.1.8     3    192.168.1.3     4    192.168.1.3     5    192.168.1.9     6    192.168.1.8     7    192.168.1.8     8    192.168.1.0     9    192.168.1.3

Can be sorted with sort command, then repeat, the result is also unique

[Email protected]:~/linux/uniqsortuniq -C      1192.168.  1.0      1192.168.  1.2      3192.168.  1.3      3192.168.  1.8      1192.168.  1.9

-D: Show only duplicate rows

[Email protected]:~/linux/uniquniq -192.168. 1.3 192.168. 1.8

Linux Common basic commands: uniq-to repeat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.