In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the example analysis of sort multi-field sorting in linux, which is very detailed and has certain reference value. Friends who are interested must finish it!
The details are as follows.
Linux most distributions come with the sort program, very powerful, here only talk about multi-field sorting
Sort has a parameter-k, which can specify fields, has more complex syntax, and is not within the scope of the text.
The following is a piece of data (obtained from the gene, just as demo), and the file name is data
Chr13 3008566 3008677
Chr9 3024384 3024515
Chr19 3157071 3157172
Chr5 3236386 3236476
Chr13 3041044 3041191
Chr12 3045343 3045532
Chr6 3087308 3087625
Chr5 3109870 3110091
Chr9 3115454 3115531
The fields are separated by spaces in the middle
Now you want to sort by chromosome first, and then the genes on the same chromosome are sorted by the starting site, so this is a multi-field sort, and the second field is a number, using the sort command as follows
Sort-t''- K1 data 1-K2n Magi 2
Where-t 'specifies the use of spaces for sorting
-K1Power1 specifies to sort by the first column keyword
-k2nmem2 specifies that the data is sorted by the second column keyword
You can also use the
Sort + 0-1 + 1n-2
The effect is the same.
Sort result
Chr12 3045343 3045532
Chr13 3008566 3008677
Chr13 3041044 3041191
Chr19 3157071 3157172
Chr5 3109870 3110091
Chr5 3236386 3236476
Chr6 3087308 3087625
Chr9 3024384 3024515
Chr9 3115454 3115531
The above is all the contents of the article "sample Analysis of sort Multi-field sorting in linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.