Method 1:
The two-day use of MAVEN in building an application, because project is very large, there are more than 700 pom.xml files, and even more depressing is that in many pom.xml files are individually specified in the repository URL, I need to assign the URLs of these repositories uniformly to the Nexus local Central library.
Manually change the file configuration is a bit less practical, so Google a bit, find the bulk of the replacement file content of a good way, the command structure is as follows:
Find-name ' file name to find ' | Xargs perl-pi-e ' s| replaced string | Replace String |g ' The following example is to replace "Pom.xml" in all http://www.111cn.net/phper/php.html files in the current directory and all subdirectories with " Http://www.111cn.net ".
Find-name ' Pom.xml ' | Xargs perl-pi-e ' S|http://www.111cn.net/phper/php.html|http://www.111cn.net|g ' uses the Perl language here,
Perl-pi-e adds the-e option to the Perl command followed by a line of code that runs the code like a normal Perl script.
Using Perl from the command line can help achieve some powerful, real-time transformations. Seriously studying regular expressions and using them correctly will save you a lot of manual editing work.
Find-name ' Pom.xml ' | Xargs perl-pi-e ' S|http://repo1.maven.org/maven2|http://localhost:8081/nexus/content/groups/public|g '
Method 2:
A simple way to bulk replace strings in multiple files under Linux. Use the SED command to bulk replace strings in multiple files.
Use the SED command to bulk replace strings in multiple files.
Sed-i "s/original string/new string/g" ' grep original string-rl directory '
For example: I'm going to replace Mahuinan with Huinanma and execute the command:
Sed-i "s/mahuinan/huinanma/g" ' grep mahuinan-rl/www '
This is the current Linux simplest batch replacement string command!
The specific format is as follows:
Sed-i "s/oldstring/newstring/g" ' grep oldstring-rl/path '
Instance code: Sed-i "s/size/Moon fire/g" ' grep size how much-RL/USR/AA '
Sed-i "s/size/Moon fire/g" ' grep size how much-rl./'
Method 3:
During the development of the schedule, perhaps you will encounter a variable name modified to another variable name, if this variable is a local variable, vi sufficient, but if it is a global variable, and in many files are used, this time using VI is an unwise choice. Here is a simple shell command to modify the specified string in all files at once:
grep "ABC" *-r | Awk-f: ' {print $} ' | Sort | Uniq | Xargs sed-i ' s/abc/abcde/g '
Supplementary Note:
Sed-i "s/oldstring/newstring/g" ' grep oldstring-rl/path '
Processing of multiple files may not be supported and needs to be done with Xargs.
Variants are as follows:
grep Oldstring-rl/path | Xargs sed-i "S/oldstring/newstring/g"
Attention:
In ' grep oldstring-rl/path ', ' the inverted quote in front of 1 ', not the '