我有以下文件:使用正則表達式
$ 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
啊!不是我想要的,我只想要第一次出現匹配的圖案範圍。當我有正則表達式作爲我的地址時,我該怎麼做?