How the shell adds content after the specified file location

Source: Internet
Author: User

Recently encountered a problem in the work, want to add a flag bit after the specified location of a file, required to be implemented in the shell script.

Problem Description:

Want to add a flag after a string of sys_config.fex text

For example, there is such a thing in Sys_config.fex

[Nand_para]

Nand_use = 1

Requires a flag = 1 to be added after [Nand_para], and finally (does not affect other content):

[Nand_para]

Flag = 1

Nand_use = 1

Specific implementation:



Reference material (http://bbs.chinaunix.net/thread-1585877-1-1.html):

Script Description:
Write "# chkconfig:2345 98 98" and "# Description:http Server" to/etc/init.d/httpd under the "#!/bin/sh" field.


I just added a parameter of-I, if not added, although the screen shows:
#!/bin/sh
# chkconfig:2345 98 98
# description:http Server


Sed-i '/#!\/bin\/sh/a\# chkconfig:2345 98 98\n# description:http server '/etc/init.d/httpd

How the shell adds content after the specified file location

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.