Article Title: replacing File Content in batches in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Maven is used to build an application in the past two days. Due to the large project, there are more than 700 pom S. xml file, even more depressing is in many pom. the url of the resource library is specified separately in the xml file. I need to uniformly specify the URLs of these resource libraries to the local central nexus library.
Manually changing the file configuration is a bit impractical, So google, find a good way to replace the file content in batches, the command structure is as follows:
Find-name 'file name to be searched' | xargs perl-pi-e's | replaced string | G'
In the following example, the "example" in the current directory and all the subdirectories of the pom. xml file
Find-name 'pom. xml' | xargs perl-pi-e's | http://repo1.maven.org/maven2 | http: // localhost: 8081/nexus/content/groups/public | G'
The Perl language is used here,
Perl-pi-e
Add the-e option to the Perl Command, followed by a line of code, and it will run the code like running a common Perl script.
Using Perl from the command line can help implement some powerful and real-time conversions. Studying Regular Expressions carefully and using them correctly will save you a lot of manual editing work.