for i in 1 2 3 4; do echo $i; done 2、测试for的自增长的循环: #!/bin/bash for ((i=1; i<=5; i++)) do echo $i; done 如果会报错,没有则跳过: Syntax error: Bad for loop variable 原因:代码对于标准bash而言没有错,因为Ubuntu为了加快开机速度,用dash代替了传统的bash,是dash在捣鬼。
把系统升级了之后(有的时候更新系统也许也会遇到),发现使用shell,运行时会有报错:Syntax error: Bad for loop variable。仔细查看语法,并没有问题。后来才知道原因: 代码对于标准bash而言没有错,因为Ubuntu为了加快开机速度,用dash代替了传统的bash,是dash在捣鬼。 解决方法是取消dash: sudo dpkg-reconfigure dash 在...
add.sh: 4: Syntax error: Bad for loop variable 代码没有错误,Ubuntu为了加快开机速度,用dash取代bash。 解决的方法:取消dash,使用bash: sudo dpkg-reconfigure dash 选择No选项。
linux shell下某些命令失效,例如< 、 >等符号,例如 : 报错 Syntax error: Bad for loop variable 在终端下执行这个:选择 否 sudo dpkg-reconfigure dash
发帖说明:http://www.fecshop.com/topic/624 如果是你自己的流水笔记,请到自己的博客里面发 hetao•#2•6年前 0 个赞 这个博客并不是我的,只是本着同样的问题别人也可能遇到另外修改脚本语法也是一种方案 hetao•#3•6年前 0 个赞 当然如果本论坛只接受bug报告,不接受fecshop有关的交流我不说什...
: 4: Syntax error: Bad for loop variable 解决办法:sudo dpkg-reconfigure dash 在选择项中选No Loong:/home# sudo dpkg-reconfigure dash [: 88: false: unexpected operator 正在删除 “diversion of /bin/sh to /bin/sh.distrib by dash”
Forexample,sayyourscriptneedstoreportaninvalidargumentthatisstoredinthe BADPARM variable. You can print the diagnostic message with the following line so that the script name appears in the error message:0变量保存脚本的名称,对于生成诊断消息非常有用。例如,假设您的脚本需要报告存储在 BADPARM变量中的...
Test-WriteError: Line | 7 | Test-WriteError | ~~~ | Bad The $? variable is: False Now the $? variable is: True 針對後者, $PSCmdlet.WriteError() 應該改用 。針對原生命令 (可執行檔),$?當為0 時會設定為 $LASTEXITCODE,當 為任何其他值時,則設定$LASTEXITCODE。注意 在PowerShell 7...
unset variable_name 变量被删除后不能再次使用。unset 命令不能删除只读变量。 实例 实例#!/bin/sh myUrl="https://www.runoob.com" unset myUrl echo $myUrl 以上实例执行将没有任何输出。 4.变量类型 运行shell时,会同时存在三种变量: 1) 局部变量 局部变量在脚本或命令中定义,仅在当前shell实例中有效...
# testing the for variable after the looping for test in Alabama Alaska Arizona Arkansas California Colorado do echo "The next state is $test" done echo "The last state we visited was $test" test=Connecticut echo "Wait, now we're visiting $test" ...