【发布时间】:2021-03-19 16:49:19
【问题描述】:
我想在几个文件中找到类似的空函数
fLocalEvent(){
}
我想用 grep 查找
我试过了:
grep -Rlz "function fLocalEventoBotoes.*[\n\s]*?}" sob/SOB910C.js
grep -Rlz "fLocalEventoBotoes\((?:(?!\)\s*\{).)*\)\s*\{\s*\}" sob/SOB910C.js - return -bash: !\: event not found
【问题讨论】:
-
您似乎在使用 PCRE。使用
grep -P切换到此正则表达式方言。 -
grep 是一种面向行的环境类型。您需要一个面向块的正则表达式,例如
Perl或Ruby或Python或awk来执行此操作。