The first column of the shell is judged as duplicates, and only one of the data is taken.

Source: Internet
Author: User

For example 123456.txt content is as follows

90115601,2137786735 36684

90115601,2137786735 36684

90118301,17751822 34898

90145133,2050186877 3847

90145133,2050186877 3847

90151825,3580430507 37974

90151825,3580430507 37974

90188754,2987861307 24533

90188754,2987861307 24533

910910,1303405168 1855

910910,514876016 1555

991314,1879979639 49504

991314,4119267805 50922

998008,1453233015 13818


Take the first piece of data

TAC 123456.txt | awk-f, '!a[$1]++ ' |sort-t, '-k1


Take the last piece of data

Cat 123456.txt | awk-f, '!a[$1]++ ' |sort-t, '-k1

The first column of the shell is judged as duplicates, and only one of the data is taken.

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.