Linux 使用基于行分隔符的grep内容提取文件内容

Linux 使用基于行分隔符的grep内容提取文件内容,linux,awk,grep,Linux,Awk,Grep,我试图使用grep、awk或任何linux命令来提取文件信息 有:文件 Getting Table 'TABLEA' GET TABLE TABLEA (value(1) ) / Getting Table 'TABLEB' GET TABLE TABLEB (value(1) ,other value(2) ) / 想要 包含以下内容的输出 Getting Table 'TABLEA' GET TABLE TABLEA (value(1) ) / 这将有助于: grep -A 4 "^

我试图使用grep、awk或任何linux命令来提取文件信息

有:文件

Getting Table 'TABLEA'
GET TABLE TABLEA
(value(1)
)
/

Getting Table 'TABLEB'
GET TABLE TABLEB
(value(1) 
,other value(2)
)
/
想要

包含以下内容的输出

Getting Table 'TABLEA'
GET TABLE TABLEA
(value(1)
)
/
这将有助于:

grep -A 4 "^Getting Table 'TABLEA'"
它将在行首获取图案,打印它,然后继续打印4行(
-A 4
选项)