1. Sed:stream Editor, Stream editors
is to handle pure ASICC plain text, line-by-line manipulation.
There are two types of editor, line editor and full screen editor
SED: Default does not edit the original file, only the data in the pattern space to do processing, and then. After processing finishes, print the mode space to the screen.
2. Format: sed ' addresscommond ' file ...
Address:
1. Startline, Endline
For example: 1,100: from 1 to 100
2./pattern/is/regexp/
Like/^root/.
3./pattern1/,/pattern2/
From the first row that is matched to a pattern, to the end of the second line that is matched by the pattern, the middle row
4. linenumber
The specified row. Note, $ represents the last line.
5. Startline, +n
Starting from Startline, a few lines backwards
Command
D: Delete rows that match the criteria
First Kind
The second Kind
Third Kind
P: Show rows that match the criteria
A recurring display that meets the criteria, not one that meets the criteria.
The role of-n
A \string: Append a new line after the specified line
I usage, format I \string: Adds a new line before the specified line, with the contents of String
R file: Adds the specified file contents to the line that matches the criteria
W File: Saves content in the specified range to the specified file
S: Find and replace
The default is to replace only the string that matches the first companion pattern in each row
Format is: s/pattern/string/
Add modifier
Format: s/pattern/string/modifier
G: Global substitution.
I: Ignore case when finding
&: Reference pattern matches entire string
-I: Direct modification of the original file (dangerous)
-E script–e script: Multiple scripts can be executed at the same time
-f/path/to/sed. SCRIPT
sed–f/path/to/scripts file
-R: Using extensions
3. Practice
6-2 sed command