Sed
SED syntax format:
Sed[options] ' command ' file (s)
Sed common options:
-N: Only the line (or action) that has been specially processed by SED is listed.
-E: Combining multiple SED commands
-F: Perform sed action within filename
-r:sed's actions support the syntax of extended formal notation.
-I: Directly modifies the contents of the read file, not the screen output
Sed common commands:
A: Append sed ' a xxx ' file after each line append xxxx sed ' $a xxx ' file last line append
I: Insert the sed ' i xxx ' file before inserting xxx into each line
C: replace sed ' 2c xxx ' file second line with XXX instead
D: Delete sed '/^$/d ' file delete blank line sed ' 1,5d ' file delete 第1-5 line
S: replace sed ' s/pattern/replace_str/g ' file/g means that SED will replace each match, otherwise it is the first match
&: A string that marks a matching style and can use matched content when replacing a string
\1 or \ 2:1th or 2nd matching string
Application:
1, &: Tag a string that matches a style, you can use matched content when replacing a string
2, \1 or \ 2:1th or 2nd matched string, \ (pattern\) for matching substring, pattern is included in () with Slash escaped
3. Combine multiple SED commands with pipelines
Sed ' expression ' | Sed ' expression '
Sed ' expression;expressiong '
Sed-e ' expression '-e ' expression '
Sed for simple operation of Linux commands