- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2012-12-13 16:44 编辑
回复 1# vectorT
s for section
k for keyword
change "old" to "new" when got the right section and keyword
$ awk 'BEGIN{s="c";k="smp2";old="you";new="I"}
/^\[/{S=($1=="["s"]")?1:0}
S&&$1==k{sub(old,new)}1' file- [a]
- smp1 = what do i do
- smp2 = how do you think
- smp3 = did it work
- [b]
- smp1 = what do i do
- smp2 = how do you think
- smp3 = did it work
- [c]
- smp1 = what do i do
- smp2 = how do I think
- smp3 = did it work
- [d]
- smp1 = what do i do
- smp2 = how do you think
- smp3 = did it work
复制代码 |
|