Chinaunix

标题: 求助shell脚本修改ini文件问题~~ [打印本页]

作者: xuecai481    时间: 2013-11-04 17:21
标题: 求助shell脚本修改ini文件问题~~
aaa.ini文件格式如下:

[module1]
a=1
b=2
[module2]
a=4
b=0
[module3]
c=4
d=0

请问高手如何在[module2]下新增一行c=8 变成如下格式,请大家多多指教,谢谢~

[module1]
a=1
b=2
[module2]
a=4
b=0
c=9
[module3]
c=4
d=0
作者: huang6894    时间: 2013-11-04 17:27
C=8还是9?
作者: xiaowurq    时间: 2013-11-04 17:30
sed '/module3/i\c=8' aaa.ini
作者: huang6894    时间: 2013-11-04 17:37
sed '/\[module3\]/i\C=8' aaa.ini
作者: xuecai481    时间: 2013-11-04 18:11
多谢各位啦,可以啦~
作者: LikeLx    时间: 2013-11-05 10:13
要是没有3 你们这些代码不全军覆没了?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2