I’m trying to run a loop that will run matlab command in the background the following way:
while [$i -lt $p] || [$i -eq $p] do
$i>i.txt
echo "matlab -nojvm -r readtxt_abc;pause(1);myfunc1(a,b,c);clear" |sh &
let i=i+1
done
and I get an error of
bash:syntax error near unexpected token 'done'
if anyone have any idea what is the reason for the error pls let me know, thank u!
Square brackets require spaces around them since they are, in essence, commands instead of syntax elements. You also need a semicolon when you put
doon the same line aswhile.The less-than-or-equal operator is
-leinstead of doing two tests.However, this is preferred in Bash:
But you can let Bash maintain your counter variable:
Perhaps the second line should be:
but I don’t know why you’d want to do that.