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 batch output different classified contents to different files by awk

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, I would like to share with you how awk batch output different categories of content to different documents of the relevant knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.

Use awk to input different types of data into different files at one time. Combined with classification and naming files, it is completed in batch.

Take the following data as an example: the data is separated by tab, based on which the second column belongs to different categories, and the data is split into different files based on these categories.

Sme2.5_00225.1_g00009.1 5 4.9101421148427 4.70706424227 4.47761327337Sme2.5_00013.1_g00022.1 2 21.1187 23.221 29.6611Sme2.5_12110.1_g00002.1 1 1.433897 1.548173362585 0.90704900000012Sme2.5_00025.1_g00018.1 6 11.5460400033104 14.7074911502 16.88622

The command is as follows: input class An into the A.group.xls file, > > redirect and ensure that the result is appended to the file without overwriting the original content

Awk-F "\ t"'{file=$2 ".group.xls"; print $0 > > file} 'test.xls

The contents of some 1.group.xls files are as follows:

Sme2.5_12110.1_g00002.1 1 1.433897 1.548173362585 0.90704900000012Sme2.5_00381.1_g00005.1 1 23.433128 27.1872800104626 30.1593730022856Sme2.5_00025.1_g00010.1 1 3.57547 3.09212 3.99896Sme2.5_03796.1_g00004.1 1 5.427584 6.413570226401 5.498800901861Sme2.5_01078.1_g00012.1 1 134 . 961 168.542 187.338Sme2.5_00283.1_g00011.1 1 54.94897 63.82024 86.65466Sme2.5_05647.1_g00003.1 1 34.37993 47.2503 52.89067Sme2.5_01073.1_g00009.1 1 38.704704 27.09380864891 30.33779317199Sme2.5_04242.1_g00007.1 1 25.9123030039 26.0802570616 32.588575144Sme2.5_00474.1 Above g00019.1 1 4.91119 5.41303 5.66823 is all the content of the article "how to batch output different classified content to different files by awk" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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.

Share To

Development

Wechat

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

12
Report