In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
How to use the sort command of linux? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
The linux sort command is sort.
Sort compares each line of the file as a unit. The principle of comparison is to compare each other from the first character to the back, then compare them according to the ASCII code value in turn, and finally output them in ascending order.
[zookeeper@master rh] $cat seq.txtbananaapplepearorangepear [zookeeper@master rh] $sort seq.txt applebananaorangepearpear
The-u option for sort
Its simple function is to remove duplicate lines from the output line.
[zookeeper@master rh] $sort-u seq.txt applebananaorangepear
Pear was mercilessly deleted by the-u option due to repetition.
-r option for sort
[zookeeper@master rh] $cat number.txt1357112461089 [zookeeper@master rh] $sort number.txt-- the default sorting method for sort is ascending order 1101123456789 [zookeeper@master rh] $sort-n number.txt-- the sorting program sorts these numbers by characters, and the sorting program will first compare 1 and 2, obviously 1 is smaller, so put 10 before 2 1234567891011 [zookeeper@master rh] $sort-n-r number.txt-r for descending order N means to sort by number 1110987654321
Other common sort options
-f converts lowercase letters to uppercase letters for comparison, that is, ignore uppercase and lowercase
-c will check whether the files are in order, if they are out of order, output the relevant information about the first disordered line, and finally return 1
-C will check whether the files are in order, and if they are out of order, they will not output the contents, only 1 will be returned.
-M will be sorted by month, for example, JAN is less than FEB, etc.
-b ignores all white space in front of each line, starting with the first visible character.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.