Linux SED Stream Editor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.