2016-10-17 80 views
0

我想只提取使用grep的两种,AWK或任何Linux命令文件信息提取文件内容

有:文件

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

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

WANT

输出包含以下

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

http://stackoverflow.com/questions/33444369/splitting-bulk -text文件,每正线 – Rao

回答

0

这将工作:

grep -A 4 "^Getting Table 'TABLEA'" 

它将在该行的开始拿到模式,打印,并继续打印4线之后(-A 4选项)