Introduction to Linux uniq command usage

Source: Internet
Author: User

uniq CommandUsed to report or ignore duplicate rows in a file, typically withSortcommand in conjunction with the.

Grammar
Uniq (option) (parameter)
Options
-C or--count: Displays the number of occurrences of the row next to each column;-D or--repeated: Displays only the repeating rows and columns;-f< fields > or--skip-fields=< columns;: Ignores the comparison of the specified field;-s< Character position > or--skip-chars=< character position;: Ignores the comparison of the specified character;-U or--unique: Displays only once in the row and column;-w< character position > or--check-chars=< character position > : Specifies the character to compare.
Parameters
    • Input file: Specifies the duplicate line file to be removed. If this item is not specified, the data is read from the standard;

    • Output file: Specifies the output file to be written to when the contents of the duplicate row are to be removed. If you do not specify this option, the content is displayed to the standard output device (display terminal).

Instance

To delete duplicate rows:

Uniq File.txtsort file.txt | Uniqsort-u file.txt

Show only one line:

Uniq-u File.txtsort file.txt | Uniq-u

Count the number of times each line appears in the file:

Sort File.txt | Uniq-c

Find duplicate lines in the file:

Sort File.txt | Uniq-d


Introduction to Linux uniq command usage

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.