Linux Shell sed (append text)

Source: Internet
Author: User

Stream editor is a text processing tool that can process all editing tasks at a time. Instead of directly modifying the file, it copies the text content to the buffer zone and then edits the content it operates on to the buffer zone. If you want to save the result, you need to redirect the buffer content to the file.

 

I learned a sed command today and failed to run it. It was very depressing. I tried it for a long time and got it done.

Command: sed 'specify address a \ text' input file

Explanation: This command appends text to the specified position of the input file. If no address is specified, it is appended to the end of each row by default.

 

The following are my actual operations: (the result is incorrect.) I am very familiar with the practice!

My environment is a UNIX experience center

I want to append the text "sed test" to the next line of the sedtestfile File"

-Bash-3.00 $ ls

Sedtestfile

-Bash-3.00 $ cat sedtestfile

1

2

3

4

5

6

7

8

9

0

-Bash-3.00 $ sed '/6/a \ sed test' sedtestfile

Sed: Command garbled:/6/a \ sed Test

An error occurs. Why can't I try it. Is there a space missing. I cannot do anything about it.

A sudden flash of light. Haha! Successful! You can guess how it works.

-Bash-3.00 $ sed '/6/.)

> SED test (enter the text you want to append here .)

> 'Sedtestfile

-Bash-3.00 $ cat sedtestfile

1

2

3

4

5

6

Sed Test

7

8

9

0

Related Article

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.