小编Tsa*_*iel的帖子

使用perl命令搜索bash for循环语法

我有几个bash脚本需要修改,我宁愿不要手工完成...基本上,它们都包含行

for ((i=${BEGIN} ; i < ${END} ; i++))
Run Code Online (Sandbox Code Playgroud)

我需要改变它

for ((i=${BEGIN}-1 ; i < ${END} ; i++))
Run Code Online (Sandbox Code Playgroud)

i = $ {BEGIN}是唯一的,并且在每个文件中只出现一次,所以我想我可以使用简单的perl命令搜索并替换它.我想出的是

>  perl -w -i -p -e "s/i=\$\{BEGIN\}/i=\$\{BEGIN\}-1/" Script.sh
Run Code Online (Sandbox Code Playgroud)

这会导致以下错误

syntax error at -e line 1, near "{BEGIN"
syntax error at -e line 1, near "}continue"
Execution of -e aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)

这里的语法错误是什么?

谢谢!

Tsadkiel

syntax bash perl

0
推荐指数
1
解决办法
122
查看次数

标签 统计

bash ×1

perl ×1

syntax ×1