Introduction and use of uniq commands in AIX

Source: Internet
Author: User
Uniq command introduction under AIX and use [plain] www.2cto. comuniq to remove or prohibit duplicate lines from a text; sort's-u option can also remove duplicate lines. Command format: uniq-u [-d [,-c]-finput_fileoutput_file-u: show only rows that are not repeated...
Uniq command introduction under AIX and use [plain] www.2cto.com uniq to remove or prohibit duplicate lines from a text; sort's-u option can also remove duplicate lines. Command format: uniq-u [-d [,-c]-f input_file output_file-u: only show non-duplicate rows-d: only show rows with duplicate data, for each duplicate row, only one row is displayed.-c: print the number of occurrences of each duplicate row.-f: n is a number, and the first n fields are ignored, if the-f option is not recognized, the system uses the-n option. let's take a look at the following example: duplicate 1 Monday 2 Monday 3 Tuesday 4 Tuesday 5 Wednesday 6 Monday 7 TuesDay 8 Thursday 9 Friday 10 Saturday 11 Sunday 12 Friday duplicated data includes Monday (, 6), Tuesday, 7), Friday (9, 12 ). Duplicate rows in the cmdweek.txt File: uniq-d week.txt Monday Tuesday. Note that only the duplicate rows Monday and Tuesday are displayed, but the duplicate row Friday is not shown. The following shows the rows that are not repeated: uniq-u week.txt Wednesday Monday TuesDay Thursday Friday Saturday Sunday Friday. note: Here there are two Fridays in the bread. aren't they repeated data? Answer: they are indeed non-duplicate data. Let's look at the number of repetitions in each row: uniq-c week.txt 2 Monday 2 Tuesday 1 Wednesday 1 Monday 1 TuesDay 1 Thursday 1 Friday 1 Saturday 1 Friday from here, we can see that Monday and Tuesday are repeated twice, but Friday appears once, not repeatedly. Originally, the same data that occurs continuously in AIX is considered as duplicate data, while the same data (Friday) does not appear consecutively. This is different from the repeated data of tables in DB2 databases. as long as the same data appears consecutively or consecutively for multiple times, it is considered to be repeated. Sort also has the function of removing duplicates: sort-u week.txt Friday Monday Saturday Sunday Thursday Tuesday TuesDay Wednesday uniq command can also be de-duplicated according to the domain. See the following example: pg parts.txt AK47 GOOD DS123 GOOD ER001 GOOD shows the number of occurrences of each row: uniq-c parts.txt 1 AK47 GOOD 1 DS123 GOOD 1 ER001 GOOD remove duplicates according to the second domain: uniq-f2 parts.txt AK47 GOOD -- the end --
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.