linux Sed (stream editor)

Sed (stream editor)

Stream EDitor sed: line editor
The default sed: mode space does not edit the original file, only the data in the mode space to do processing; and then, after the end of the processing, the pattern space is printed to the screen

sed [options]'AddressCommand'file file...

-n: silent mode, the default display mode is no longer content
-i: directly modify the original file
Script -e: multiple scripts can be executed at the same time
/PATH/TO/SED_SCRIPT -f
Sed -f /path/to/scripts file eg.
-r: representation using extended regular expressions

Address:

1. StartLine,EndLine
For example 1,100
$: the last line
2. /partten/
Such as /^root/
3. /patten1/,/patten2/
The first time was patten1 matched to the line to start, to the end of the first pattern2 to be matched to the line, the middle of all lines
4. LineNumer
Specified line
5. StartLine,+N
Starting from StartLine, the backward N line

Command:

d: delete line with the conditions
p: display line with the conditions
a \string: at the end of the row specified additional content for the string line,
i \string: in front of the specified line add newlines, the content of string
r FILE: adds the contents of the specified file to the line of the line.
w FILE: will specify the contents of the specified range to the specified file.
s/partten/string/ modifier: find and replace the default, only the replacement string in each row is matched to the first mode
         Modifier
         g: global replacement
         i: ignore character size
s### s@@@ s/// : Separator can be customized
&: reference pattern matching to the whole string

Pingbacks are open.

Trackbacks

Trackback URL

Comments are closed.