我有一個包含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命令無法捕獲多行註釋。我知道,我需要打印所有以「評論」文本開頭的行,直到第一次出現「;」包含多行註釋這也意味着要在不以「評論」語句開頭的行之間打印。
在此先感謝您的任何建議。
你可以發佈一些你已經做過的嘗試嗎? –