我正在关注此sed教程:http://www.grymoire.com/unix/Sed.html#uh-29
并编写以下命令来处理python"" zen;座右铭,如:
sed '/Although/,/There/ s/a/A/g' zen
Special cases aren't special enough to break the rules.
Although prActicAlity beAts purity.
Errors should never pAss silently.
Unless explicitly silenced.
In the fAce of Ambiguity, refuse the temptAtion to guess.
There should be one-- And preferAbly only one --obvious wAy to do it.
Although thAt wAy mAy not be obvious At first unless you're Dutch.
Now is better thAn never.
似乎启动模式运行良好但停止模式不起作用!
如何解决?
答案 0 :(得分:2)
实际上你的停止模式确实有效。但是,嘿,看:
Special cases aren't special enough to break the rules.
>>> Although <<< prActicAlity beAts purity. # Start
Errors should never pAss silently.
Unless explicitly silenced.
In the fAce of Ambiguity, refuse the temptAtion to guess.
>>> There <<< should be one-- And preferAbly only one \
--obvious wAy to do it. # Stop
>>> Although <<< thAt wAy mAy not be obvious At first unless \
you're Dutch. # Start again!
Now is better thAn never.
你有另一个开始模式(Although
字)后面的行!所以sed
再次开始替代。这就是全部。将第二个Although
替换为文本中的其他内容,或选择Although p
作为开始模式,一切都按预期工作。