Vi replacement, vi
In the vi editor, you can use the: s command to replace strings. The specific usage is as follows:
1.: s/str1/str2/replace str1, the first character string that appears in the line with string str2;
2. s/str1/str2/g: replace str1 with string str2;
3.:., $ s/str1/str2/g. Use string str2 to replace all the strings str1 from the current row to the end of the body;
4.: 1, $ s/str1/str2/g replace str1 with string str2;
5. The functions of g/str1/s // str2/g are the same as those of 4.
At the end of the command, it indicates to replace each appearance of the search string. If no g is added, it means to replace the first appearance of the search string. g is placed at the beginning of the command, replaces all rows in the body that contain search strings.
Replacement in vi
: % S/stLoanCom. memocode/stLoanCom. xxxxxxx/g
Sed can be used. sed's/stLoanCom. memocode/stLoanCom. xxxxxxx/G' file
Multiple files
For I in *. c; do
Sed's/stLoanCom. memocode/stLoanCom. xxxxxxx/G' "$ I"> file2
Mv file2 "$1"
Done
In linux, how does one replace the same character with the vi editor?
1) Single Character replacement: In command mode, place the cursor in the character to be replaced, press r, and then press the required character;
2) Replace string: $ s/string/replae/g in command mode
Replace the full-text string with the replace string, where 1 and $ s indicate that the search interval is from the beginning to the end of the article, and g indicates that all replications do not need to be confirmed.
% S/string/replace/c: replace the full-text string with the replace string, which is different from the preceding command: % s and 1, $ s is the same function, and c indicates that you must confirm whether to replace it before replacement.
1, 20 s/string/replace/g: replace the string between 1 and 20 lines with the relpace string.