1. Replace command in VI mode:
s = replace (substitute), G for global search
: s/vivian/sky/replaces the current line the first Vivian is sky
: S/vivian/sky/g replaces the current line all Vivian are sky
: N, $s/vivian/sky/replaces the first Vivian of each row in the nth row to the last row is sky
: N, $s/vivian/sky/g replace the nth line to the last row all Vivian are sky
N is a number, if N is., indicating the beginning of the current line to the last row
:%s/vivian/sky/(equivalent to: g/vivian/s//sky/) replaces the first Vivian of each line as Sky
:%s/vivian/sky/g (equivalent to: g/vivian/s//sky/g) replaces all Vivian in each row as Sky
You can use # as a delimiter, at which time the middle/not as a delimiter
: s#vivian/#sky/# Replace the current row the first vivian/is sky/
:%s+/oradata/apras/+/user01/apras1+ (use + to replace/):/oradata/apras/Replace with/user01/apras1/
2. Replace the string contents in the file:
Find-name ' filename to look for ' | Xargs perl-pi-e ' s| replaced string | replaced string |g '
The Xargs:find command passes the matched file to the Xargs command, and the Xargs command takes only a subset of the files at a time instead of all, unlike the-exec option. So it can handle the first fetch
Part of the file, then the next batch, and so on.
Perl:perl-pi-e The Perl command with the-e option followed by a line of code, it runs the code as if it were running a normal Perl script. Using Perl does not generate intermediate files in the conversion process,
Execute quickly i-parameters edit files directly in situ.
3. Replace the strings in multiple folders:
Sed-i "s/original string/new string/g" ' grep original string-rl directory '
-I parameter: Operate directly on the original file
-F: The action of SED is written directly in a file, and-f filename can perform the SED action within filename;
-r:sed's actions support the syntax of extended formal notation. (Presupposition is the basic formal notation of French law)
Note: The following "grep original string-rl directory" is not enclosed in single quotes. Instead, it is caused by "'" in the Key "~" in the keyboard.
sed command to replace multi -level catalogs
Linux common commands (replace)