Linux replace sed command reprint

Source: Internet
Author: User

    • Reproduced from here, thanks to the original author
    • sed ‘s/test/mytest/g‘ example.txt
    • Indicates that the test text in Example.txt is replaced with mytest

    • Please note that this command sed ‘s/test/mytest/‘ example.txt

    • If you do not have g, you will only replace the test with mytest at the beginning of each line.

    • sed ‘^s\test\mytest\p‘Example.txt

    • Replace the first occurrence of the test with mytest for each line and print only the rows that were replaced

    • sed ‘s#10#100#g‘Replace 10 in text with 100

    • #Equivalent /

    • sed -n ‘/test/,/check/p‘ example.txtRepresents the line between the print test and the check

    • test/,/checkIndicates that the row between test and check appears

      + sed -n ‘5,/^test/p‘ example.txt Print line 5th to the first occurrence of test

Linux replace sed command reprint

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.