admin管理员组文章数量:1320864
I have an odbc.ini file similar to this
[Test]
Driver=/path/to/driver
Database=test_db
[AnotherSection]
Driver=/another/pathhere
when I run below command, it is adding the Password=5432 at the beginning of the section. Instead I need it at the end of the section [Test]
sed '/^\[Test\]/ a Password=5432}' odbc.ini
[Test]
Password=5432
Driver=/path/to/driver
Database=test_db
[AnotherSection]
Driver=/another/path
expected:
[Test]
Driver=/path/to/driver
Database=test_db
Password=5432
[AnotherSection]
Driver=/another/path
Any suggestions please
I have an odbc.ini file similar to this
[Test]
Driver=/path/to/driver
Database=test_db
[AnotherSection]
Driver=/another/pathhere
when I run below command, it is adding the Password=5432 at the beginning of the section. Instead I need it at the end of the section [Test]
sed '/^\[Test\]/ a Password=5432}' odbc.ini
[Test]
Password=5432
Driver=/path/to/driver
Database=test_db
[AnotherSection]
Driver=/another/path
expected:
[Test]
Driver=/path/to/driver
Database=test_db
Password=5432
[AnotherSection]
Driver=/another/path
Any suggestions please
Share Improve this question asked Jan 17 at 22:07 user3795378user3795378 254 bronze badges1 Answer
Reset to default 2With GNU sed:
sed -e '/\[Test\]/,/^$/{/^$/{i Password=5432' -e '}}' file.ini
Output:
[Test] Driver=/path/to/driver Database=test_db Password=5432 [AnotherSection] Driver=/another/pathhere
I assume that the section is followed by a blank line.
本文标签: bashUpdate odbcini file with new parameter in the section using shell scriptingStack Overflow
版权声明:本文标题:bash - Update odbc.ini file with new parameter in the section using shell scripting - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742089103a2420157.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论