Show duplicate lines in linux uniq

Source: Internet
Author: User
Linux displays duplicate lines of uniq-general Linux technology-Linux technology and application information. The following is a detailed description. Uniq [Option] File

Note: This command reads the input file and compares adjacent lines. Under normal circumstances, the second and later repeated rows are deleted, and the row comparison is performed based on the sorting sequence of the character set used. The result after processing the command is written to the output file. The input and output files must be different. If the input file is expressed as "-", it is read from the standard input.

The options of this command are as follows :,

-C: In the output, add the number of times this row appears in the file at the beginning of each row. It can replace the-u and-d options.

-D: only duplicate rows are displayed.

-U only displays rows that are not repeated in the file.

-N the first n fields are ignored together with the blank space before each field. A field is a non-space, non-tab string, separated by tabs and spaces (the Field starts from 0 ).

+ N the first n characters are ignored, and the previous characters are skipped (the characters start from 0 ).

-F n is the same as-n, where n is the number of fields.

-S n is the same as + n, where n is the number of characters.

For example:

1. Show non-repeated rows in the file example.

Uniq-u example

2. Show the non-repeated rows in the file example, starting from the 2nd characters of the 2nd fields.

Uniq-u-1 + 1 example

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.