Sed is one of the Three Musketeers of the Linux command, which is the abbreviation of Stream editor, and the meaning is the abbreviation of the flow editors.
It is good at fetching, replacing, filtering. This is a bit like awk, but awk is fetching columns, but SED is fetching.
Usage: sed-n '/filtered content/processed commands/' filename
-N is the default output for canceling sed.
-P is the meaning of printing.
-I changes the contents of the file.
-R fruit does not need r parameters in regular expressions to use a lot of \ To cast, if you use R can directly write regular expressions, rather than write so many \
= line number can be represented.
SED is replaced by a wide range of applications.
s refers to commonly used find and replace, replacing one string with another.
G is used in conjunction with S, which represents a global match substitution for the current row (different from the next G meaning), and if you do not add a G to replace the first column, it is not replaced globally.
#是分隔符, you can replace them with other symbols.
-I is replaced and modified.
The format is: sed ' s## #g '
Example: sed ' s#oldboy#oldgirl#g ' test.txt but only the content of the output is modified, and the file entity is not modified.
Sed-i ' s#oldboy#oldgirl#g ' test.txt plus-I can change the content.
find/root/data/-type f-name "test.txt" |xargs sed ' s#oldboy#oldgirl#g ' is an example of a combination of find and sed replacements,
Use the SED command to remove the IP address within the ifconfig:
Ifconfig Eth0|sed-nr ' s#^.*addr: (. *) B.*$#\1#GP '
about how SED is used