我有一个多行文档,我希望从中提取特定关键字和之后的单词。它看起来像这样:
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
有没有办法做到这一点?