“bad for loop variable”可能的原因 出现“bad for loop variable”错误通常是因为在使用不支持C风格循环的shell(如dash)来执行包含C风格循环的脚本。Ubuntu等Linux发行版为了加快开机速度,可能会将默认的/bin/sh链接到/bin/dash,而不是传统的/bin/bash。而dash不支持C风格的for循环语法。 解决“bad for loop ...
add.sh: 4: Syntax error: Bad for loop variable 代码没有错误,Ubuntu为了加快开机速度,用dash取代bash。 解决的方法:取消dash,使用bash: sudo dpkg-reconfigure dash 选择No选项。
##for((i=0; i<10; i++));doecho Good Morning ,thisis$i shell program. done 执行:sh test.sh 报下面的错误. Syntax error: Bad for loop variable 在网上搜索了一下. 因为Ubuntu为了加快开机速度,用dash代替了传统的bash,所以我们这样执行就没问题. bash test.sh 那如果我们只想用sh test.sh 这...
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
写shell脚本时碰到了这样的一个问题,脚本中一个循环语句采用了类C风格的for循环,结构如下 for ((i=1;i<=20;i++)) do ... ... done 但在本人ubuntu10.04的机器上运行此脚本会出现如下错误。 ./t.sh: 2: Syntax error: Bad for loop variable ...
for循环Linux中shell命令中的两个变量 我正试图根据表在loop.Table的shell脚本中放入两个变量,如下所示: 我当前使用的代码: for i in 16 19 65 77; do sh cacul.aft.sh --aftfile /path/folder/aft${i} --red-file cla164.input --out /path/folder/re/cla164.aft${i}...
通常shell脚本遇到的情况是,你将一系列值都集中存储在了一个变量中,然后需要遍历变量中的整个列表。 #!/bin/bash # using a variable to hold the list list="Alabama Alaska Arizona Arkansas Colorado" list=$list" Connecticut" #代码还是用了另一个赋值语句向 $list变量包含的已有列表中添加(或者说是拼接)...
Why did this print 00? Because the shell saw $1, which is a shell variable (we’ll cover it soon). So you might think that if you surround it with double quotes, the shell will leave the $1 alone. But it still doesn’t work: ...
The command prompt in the terminal does not reflect the new hostname until you either log out of the switch or start a new shell. Configure the Time Zone The default time zone on the switch is UTC (Coordinated Universal Time). Change the time zone on your switch to be the time zone ...