Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of sort and uniq

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Sort is used to sort text by line, which is arranged by default in the order of ascii characters

Sort-n sorts according to the order of number size

Sort-r reverse sort

Sort supports processing multiple files and combining multiple files into one text processing

Uniq is a deduplicated command that removes duplicate lines. Note that only consecutive lines are removed.

Uniq-c counts and displays the number of duplicate rows

Uniq is often combined with sort:

Sort file | uniq-c

Uniq and sort form set operations:

Suppose there are two files: file1 and file2

1. Finding the intersection is the result of outputting the same lines of the two files:

Sort file1 file2 | uniq-d

two。 Union set

Sort file1 file2 | uniq

3. Find the difference set that appears only in file1

Sort file1 file2 file2 | uniq-u

4. Find the symmetric difference: that is, the union of file1 and file2 minus the intersection of file1 and file2, that is, only in file1 or file2

Sort file1 file2 | uniq-u

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report