文件如下所示:
[section1]
a=something
[section_name2]
a=something
[section3]
a=something
我如何a=someother
仅替换section_name2
?
答案1
使用地址范围:
sed '/\[section_name2\]/,/^\[/ s/a=something/a=someother/'
文件如下所示:
[section1]
a=something
[section_name2]
a=something
[section3]
a=something
我如何a=someother
仅替换section_name2
?
使用地址范围:
sed '/\[section_name2\]/,/^\[/ s/a=something/a=someother/'