SED is the short name of the stream editor, which is the stream editors. Stealing a picture explaining the principle
Command format:
sed [OPTION] ... {script-only-if-no-other-script} [input-file] ...
Options:
sed the action editor; The action of sed is written in a file,-f filename can execute the SED command within filename,-R enables the SED command to support extended regular expressions (default is the underlying regular expression); Directly modifies the contents of the read file, rather than the output by the screen.
Common commands
A \text append is appended with a string, followed by the string s (multiline string can be separated by \ n), then the currently selected line is followed by a string s;c \text replace/replace string, c \ followed by the string s (multiline string can be separated by \ n), The currently selected line is replaced with a string s;d that is deleted, the command will delete the currently selected row, I \text insert is inserted string, i \ followed by the string s (multiline string can be separated by \ n), the string will be inserted before the currently selected line s;p print printing, The command prints the currently selected line to the screen; s/pattern/string/substitution, usually using the S command: 1,2s/old/new/g, replacing the old string with the new string delimiter enables modifiers such as the/# @ G: Global I: Ignore case
W/path/to/somefile preserves the pattern space to match the line to the specified file
Cases:
Linux SED Stream Editor