我有一个包含SQL的文件,它有几个创建表命令,后面跟着一些表/列的注释。文件看起来像这样需要grep来自SQL文件的所有评论
create table abc
(col1, ..,..);
comment on table abc is 'This is a single line comment';
comment on column abc.col1 is 'This is a multi-line comment.
One more line of description here';
comment on column abc.col2 is 'This is a single line comment';
create table mno
(col1, ..,..);
comment on table mno is 'This is a multi-line comment.
One more line of description here';
comment on column mno.col1 is 'This is a single line comment';
collect statistics on mno column (column1);
简单的grep命令无法捕获多行注释。我知道,我需要打印所有以“评论”文本开头的行,直到第一次出现“;”包含多行注释这也意味着要在不以“评论”语句开头的行之间打印。
在此先感谢您的任何建议。
你可以发布一些你已经做过的尝试吗? –