我有一个多行文档,我希望从中提取一个特定的关键字和之后的单词。它看起来像这样:
This is key word1 line 1.
This is line 2.
This is key word2 line 3.
如果我使用egrep 'key [^s]+ '
,则输出为:
This is key word1 line 1.
This is key word2 line 2.
但是,我希望输出只是匹配而不是整行,即:
key word1
key word2
有办法吗?