我有以下文件:
$ cat file
> First line
> Second line
> Third line
> Fourth and last line
> First line
> Second line
> Third line
> Fourth and last line
我想打印前 3 行,很简单:
$ sed -n '1,3p' file
> First line
> Second line
> Third line
现在我想从事件打印First
到事件Third
:
$ sed -n '/First/,/Third/p' file
> First line
> Second line
> Third line
> First line
> Second line
> Third line
啊! 不是我想要的,我只想要匹配的模式范围的第一次出现。当我有 regex' 作为我的地址时,我该怎么做?