Compare and merge Linux files to find duplicate rows

Source: Internet
Author: User

Key commands

Sort, uniq, cat Merge multiple files cat file1 file2> newfile view repeat sort file1 in the file | uniq-d view only one sort file in the file | uniq-u more detailed command, please refer to the explanation of sort, uniq, and CAT commands uniq -- Help

$ Uniq -- Help
Usage: uniq [Option]... [input [Output]
Discard all but one of successive identical lines from input (or
Standard input), writing to output (or standard output ).

Mandatory arguments to long options are mandatory for short options too.
-C, -- count prefix lines by the number of occurrences
-D, -- repeated only print duplicate lines
-D, -- all-repeated [= delimit-method] print all duplicate lines
Delimit-method = {none (default), prepend, separate}
Delimiting is done with blank lines.
-F, -- skip-fields = n avoid comparing the first n Fields
-I, -- ignore-case ignore differences in case when comparing
-S, -- skip-chars = n avoid comparing the first n characters
-U, -- Unique only print unique lines
-W, -- check-chars = n compare no more than n characters in lines
-- Help display this help and exit
-- Version output version information and exit

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.