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