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 use the sed method of linux to process files in batch

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "how to use linux's sed method to process files in batches". In daily operation, I believe many people have doubts about how to use linux's sed method to deal with files in batches. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to use linux's sed method to deal with files in batches". Next, please follow the editor to study!

We often encounter situations where newline characters are replaced by commas: for example, someone gives you an excel, and one of the columns is id, and we need to query database data through id, which is generally as follows:

Select * from t where id in (xmeme xmeme x)

The common method at this time is to copy out the column, put it in the text, and replace it with a regular expression:

Vim a.txt:%s/\ nUniverse Magazine WQ

But when it comes to a batch of files that need to be handled in this way, it's too cumbersome to open a vim. Naturally, I thought of sending the command s /\ nUniverse to each file for execution. After a search, the sed command came into sight. But tools like sed,awk are line-oriented, so at first

Sed's /\ nCompact'* .txt

It didn't bring any effect. After another search, I found that sed has an advanced usage. Read the next line. At the same time, the cycle is carried out by using: a * ta, and all replacements are realized.

Sed-I': a * txt. At this point, the study on "how to use linux's sed method to batch process files" is over. I hope to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report