【问题标题】:Extract file content using grep content based on a line delimiter使用基于行分隔符的 grep 内容提取文件内容
【发布时间】:2016-10-17 18:46:12
【问题描述】:

我正在尝试使用 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)
)
/

【问题讨论】:

标签: linux awk grep


【解决方案1】:

这会奏效:

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

它将获取行首的模式,打印它,然后继续打印4行(-A 4选项)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-28
    • 1970-01-01
    相关资源
    最近更新 更多