我使用Perl来搜索和替换多个正则表达式:当我执行以下命令时,我收到一个错误:
prompt> find "*.cpp" | xargs perl -i -pe 's/##(\W)/\1/g' -pe 's/(\W)##/\1/g'
syntax error at -e line 2, near "s/(\W)##/\1/g"
Execution of -e aborted due to compilation errors.
xargs: perl: exited with status 255; aborting
Run Code Online (Sandbox Code Playgroud)
多个-e在Perl中有效,那为什么这不起作用?这个问题有方法解决吗?
dpp*_*dpp 40
Several -e's are allowed.
You are missing the ';'
find "*.cpp" | xargs perl -i -pe 's/##(\W)/\1/g;' -pe 's/(\W)##/\1/g;'
Run Code Online (Sandbox Code Playgroud)
Perl statements has to end with ;.
Final statement in a block doesn't need a terminating semicolon.
So a single -e without ; will work, but you will have to add ; when you have multiple -e statements.
| 归档时间: |
|
| 查看次数: |
7716 次 |
| 最近记录: |