Linux bash-sed

Source: Internet
Author: User
Tags first string modifier

Sed:stream Editor

  • Role

Read by line, pattern matching, processing display. By default, the source file is not edited, only the data in the pattern space is processed, and then the pattern space is printed.

  • Options

-N: Silent mode. The content in the pattern space is not displayed.

-I: Modify the source file directly.

-e script-e script: Executes multiple scripts at the same time.

-f/path/to/sed_script: Processes the file using the specified script.

-R: Use extended regular expressions.

  • Address designation

Startline,endline: Specifies the starting line to the end line.

LineNumber: Exact a row.

$: Represents the last row.

Startline,+n: The N-line backward from the specified line.

/pattern/: Specifies the mode.

/pattern1/,/pattern2/: The first time the line that is matched by pattern 1 starts to the end of the line that is first matched by pattern 2, and all the rows in the middle.

  • Command

D: Delete rows that match the criteria.

P: Displays rows that match the criteria.

A \string: Appends a new line to the specified line, with the contents of string.

I \string: Adds a new row before the specified line, with the contents of string.

R file: Adds the contents of the specified file to the line where the condition is met.

W File: Saves content in the specified range to the specified file.

s/pattern/string/modifier: Find and Replace, default replaces only the first string in each line that is matched. You can use "/", "#", "@" as the delimiter.

Modifier:

G: Global substitution.

I: Ignores character case when looking up.

&: References all strings that match.

Linux bash-sed

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.