Use of the linuxuniq command

Source: Internet
Author: User
Use of the linuxuniq command-general Linux technology-Linux technology and application information. For details, refer to the following section. Uniq command: displays unique rows. Only one row is displayed for repeated rows!

The following example shows how to use it:

[Root @ stu100 ~] # Cat test
Boy took bat home
Boy took bat home
Girl took bat home
Dog brought hat home
Dog brought hat home
Dog brought hat home

View the content of the test file, and you can see the repeated rows.

[Root @ stu100 ~] # Uniq test
Boy took bat home
Girl took bat home
Dog brought hat home

The uniq command only displays duplicate rows once without adding any parameters.

[Root @ stu100 ~] # Uniq-c test
2 boy took bat home
1 girl took bat home
3 dog brought hat home

-The c parameter shows the number of consecutive occurrences of each row in the file.

[Root @ stu100 ~] # Uniq-d test
Boy took bat home
Dog brought hat home

-D option only displays the rows that repeatedly appear in the file.

[Root @ stu100 ~] # Uniq-u test
Girl took bat home

-U option shows that there are no consecutive rows in the file.

[Root @ stu100 ~] # Uniq-f 2-s 2 test
Boy took bat home

Ignore the first two fields of each line, ignore the first character of the second blank character and the third field, and the result is at home

[Root @ stu100 ~] # Uniq-f 1 test
Boy took bat home
Dog brought hat home

Ignore the first field of each line. In this way, the line starting with "boy" and "girl" appears to be a row that repeats continuously.

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.