格雷普(Grep)排除评论,如尾巴

发布于 2025-01-24 18:08:35 字数 469 浏览 3 评论 0原文

我有正则是:

grep -iE 'UTL_FILE[\. ]*(FCOPY|FGETATTR|FOPEN|FOPEN_NCHAR|FREMOVE|FRENAME|fopen)' 

我想将其扩展以排除所有以任何数量的with with空间开头的评论,

例如,“ - ”获取下一行(这已经由正则表达式完成):

 l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); 

但是忽略这样的行:

 --l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); or
       --  l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); 

I have the regex:

grep -iE 'UTL_FILE[\. ]*(FCOPY|FGETATTR|FOPEN|FOPEN_NCHAR|FREMOVE|FRENAME|fopen)' 

And I would like to extend it to exclude all the lines which are comments starting with any number of withe spaces and '--'

For example, get the next line (This is already done by the regular expression):

 l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); 

But ignore lines like this:

 --l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); or
       --  l_output := utl_file.fopen(p_RutaLocal, Nombre_Archivo,'w'); 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赴月观长安 2025-01-31 18:08:35

将两个grep一起处理:

grep -v '^[[:space:]]*--' | grep -iE ...

-v选项打印不匹配的行。

Pipe two greps together:

grep -v '^[[:space:]]*--' | grep -iE ...

The -v option prints lines that don't match.

旧竹 2025-01-31 18:08:35

建议尝试:

 grep -Ev "^[[:space:]]*--"|grep -iE 'UTL_FILE[\. ]*(FCOPY|FGETATTR|FOPEN|FOPEN_NCHAR|FREMOVE|FRENAME|fopen)' 

Suggesting to try:

 grep -Ev "^[[:space:]]*--"|grep -iE 'UTL_FILE[\. ]*(FCOPY|FGETATTR|FOPEN|FOPEN_NCHAR|FREMOVE|FRENAME|fopen)' 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文