sed( Stream editor), line editors
sed [option]: ' Scrip ' Inputfile
Scrip ' Address command '
Do not give address: the full text of the processing
Single Address:
#: Specified line $: last row
/pattern/: Each row that can be matched by this pattern
Address range
#,#
#,+#
/part/,/part2/
#,/part1/
~: Step forward
Odd lines
2~2 even rows
Common options:
-N Close Printed content
-R using extended regular expressions
-e Multi-point editing
-I bak: Backing up files and editing them in situ
-R supports the use of extended regular expressions
Edit command:
d Delete matching rows for spatial pattern
P Print Current Space content
D Delete
! Pattern Match Inversion
= Pattern Space Line Plus line number
A[\]text: Append text after the specified line
Support for multi-line append using \ n
I[\]text: Inserting text in front of a row
C[\]text: Replacing a line of behavior or multiple lines of text
W/path/somefile: Save the pattern matching line to the specified file
R/path/somefile: Reads the text from the specified file to the line in the pattern space
=: Prints line numbers for lines in pattern space
! : Matching row inversion in pattern space
SED tools
s///: Find replacement, support using other separators, [email protected]@@,s###
Replace tag:
G: In-line global substitution
P: Show the rows that were successfully replaced
W/path/tosomefile: Saving a successful replacement row to a file
Advanced editing commands
P: Print mode space start to \ n content, and append to default output
H: Overwrite the contents of the pattern space in the hold space
H; Append the contents of the pattern space to the hold space
G: Overlay content in the hold space into the pattern space
G: Append the contents of the hold space to the mode space
X swap the content in the pattern space with the content in the hold space
n overwrites the next line of the row that matches the read to the pattern space
N reads the next line of the matched row to append to the
D Delete rows in the pattern space
D: If the pattern space contains a newline character, the text in the pattern space until the first line break is deleted, and the new input line is not read, and the loop is restarted using the pattern space of the composition. If the pattern space does not contain a newline character, the normal new loop is started as if the D command was emitted
linuxday10--Text Processing tool SED