SED: Line processing command, default does not modify the original file, only the data in the pattern space to do processing, after processing, the mode space to print to the screen
sed [options] ' addresscommand ' file ...
-N: Silent mode, content not in the default display mode space
-I: Modify the original file directly
-E:SCRIPT-E script: Multiple scripts can be executed at the same time
-f/path/to/sed_script
-R: Using extended regular expressions
Command
D: Delete rows that match the criteria
P: Show rows that match the criteria
A \string: Adds a new line before the specified line, the content string
\ n: can be used for line wrapping
I \string: Adds a new line after the specified line, the content string
R file: Adds the contents of the specified file to the qualifying line
W file: Save the row in the range specified by the address to the specified file;
s/pattern/string/: Find and Replace, default replaces only the first string in each line that is matched to the pattern
Sed ' s/^//#/'/etc/fstab
Modifier:
G: Global Substitution
Sed ' s/\//#/g '/etc/fstab
I: Ignore character case
S///:s###:[email protected]@@
&: Reference pattern matching
Address
1,startline,endline
Like 1,100.
$: Last line
2,/regexp/Regular Expressions
/^root/
3,/pattern1/,/pattern2/
The first line that is matched by the pattern1 begins at the end of the line that is first matched to the pattern2, and all the rows in the middle
4,linenumber
The specified row
5,startline,+n
Starting from Startline, n rows backward;
History | Sed ' s#[[:space]] '
This article is from the "Time and Space" blog, please be sure to keep this source http://tccsl.blog.51cto.com/4387692/1621949
Shell base SED usage