Simple Linux Command Line notes: uniq

Source: Internet
Author: User
ArticleDirectory
    • Parameters
    • Option
    • Example

Show unique rows

Uniq [Options] [Input-File] [Output-File]

 

Uniq is used to display its input. Only one row is retained for consecutive duplicate rows. If the files are sorted, uniq ensures that the same two rows are not displayed.

 

Parameters

If noInput-File, ThenUniqThe data is read from the standard input. If noOutput-File, ThenUniqWrite to standard output

 

Option

-C: the number of times that the row appears in the input file at the beginning of the row.

-D: displays a copy of the duplicate row. No duplicate row is displayed.

-The first n columns are skipped during the f comparison.

-I: Ignore the case sensitivity when comparing rows.

-S n ignore the first n characters in each line

-U only displays rows that do not repeat

-W n does not compare the content after the nth character in each line

 

Example

Original file

 
$CatTest boy took bat homeboy took bat Homegirl took bat homedog brought hat home

 

Uniq
 
$UniqTestboy took bat Homegirl took bat homedog brought hat home

Show duplicate rows only once

 

Uniq-C
$Uniq-C Test2Boy took bat home1Girl took bat home3Dog brought hat home

Displays the number of consecutive occurrences of each row in a file.

 

Uniq-d
 
$Uniq-D testboy took bat homedog brought hat home

Show duplicate rows only

 

Uniq-u
 
$Uniq-U test girl took bat home

Only show rows that do not appear repeatedly

 

Uniq-F-S
 
$Uniq-F2-S2Test boy took bat home

Skips specified columns and characters for comparison.

 

Related Article

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.