In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to replace file content in batches under Linux system, in response to this problem, this article details the corresponding analysis and solution, hoping to help more small partners who want to solve this problem find a simpler and easier way.
In the past two days, I used maven to build an application. Because the project is very large, there are more than 700 pom.xml files. What is more frustrating is that many pom.xml files specify the url of the resource library separately. I need to specify the url of these resource libraries to the nexus local central library.
Changing file configurations manually one by one is a bit impractical, so I did a little google and found a good way to replace file contents in batches. The command structure is as follows:
find -name 'file name to find'| xargs perl -pi -e 's| Substituted string| Substituted string| g'
The following example replaces "http://repo1.maven.org/maven2" with "http://localhost:8081/nexus/content/groups/public" in all pom.xml files in the current directory and all subdirectories.
find -name 'pom.xml' | xargs perl -pi -e 's|http://repo1.maven.org/maven2|http://localhost:8081/nexus/content/groups/public|g'
Here's Perl,
perl -pi -e
Add the-e option to a Perl command followed by a line of code, and it will run the code like a normal Perl script.
Using Perl from the command line can help with some powerful, real-time transformations. Studying regular expressions carefully and using them correctly will save you a lot of manual editing.
About Linux system how to batch replace the file content of the answer to the problem shared here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.
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.