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

How to re-count by linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is to share with you about how to re-count linux. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

The linux command line provides very powerful text processing capabilities, and the combination of linux commands can achieve many powerful functions. This article gives an example of how to use the Linux command line to de-duplicate text by line and sort by number of repeats. The main commands used are sort,uniq and cut. Among them, the main function of sort is sorting, the main function of uniq is to remove the weight of adjacent text lines, and cut can extract the corresponding text columns from the text lines (to put it simply, it is to operate the text lines by column).

The lines of text are de-duplicated and sorted by the number of repetitions

Example:

First, the lines of text are deduplicated and the number of repetitions is counted (the uniq command plus the-c option allows you to count the number of repetitions).

$sort test.txt | uniq-c 2 Apple and Nokia. 4 Hello World. 1 I wanna buy an Apple device. 1 My name is Friendfish. 2 The Iphone of Apple company.

Sort the lines of text by the number of repetitions.

Sort-n recognizes the number at the beginning of each line and sorts the lines of text by their size. The default is to sort in ascending order, and add the-r option (sort-rn) if you want to sort in descending order.

$sort test.txt | uniq-c | sort-rn 4 Hello World. 2 The Iphone of Apple company. 2 Apple and Nokia. 1 My name is Friendfish.

The number of deletions repeated before each line.

The cut command can manipulate lines of text by column. You can see that the previous repetition accounts for eight characters, so you can use the command cut-c 9-to fetch the ninth and subsequent characters on each line.

$sort test.txt | uniq-c | sort-rn | cut-c 9-Hello World. The Iphone of Apple company. Apple and Nokia. My name is Friendfish. I wanna buy an Apple device. Thank you for reading! About linux how to re-statistics to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

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