Why nohup does not accept for loop?

1

I have this code inside a file called test.sh When I try to run

nohup ./teste.sh &
 he gives this error. Can anyone explain me?
./ teste.sh: 9: ./teste.sh: Syntax error: Bad for loop variable

CODE


cuda="cuda.out";
cpu="cpu.out";
cudaTxt="cuda.out.txt";
cpuTxt="cpu.out.txt";
trash="/dev/null";
rm -f $cudaTxt;
rm -f $cpuTxt;

for ((i=10001;i<=1000001;i+=10000)); do echo "Cuda, $i iteração"; head -n$i formulas.txt > formulas_pre-processadas_CUSTOMIZADA.txt; echo -en "$i\t" >> $cudaTxt; ./$cuda | cut -c19- >> $cudaTxt; done;

for ((i=10001;i<=1000001;i+=10000)); do echo "CPU, $i iteração"; head -n$i formulas.txt > formulas_pre-processadas_CUSTOMIZADA.txt; echo -en "$i\t" >> $cpuTxt; ./$cpu | cut -c19- >> $cpuTxt; done;

echo "Acabou";

    
asked by anonymous 16.06.2018 / 19:10

1 answer

0

Change for ((i = 10001; i <= 1000001; i += 10000)); to

i = 1
while [ $((i += 10000)) -le 1000001 ]
do
    ...
done;

EDIT: This loop format that you used is not supported by all shell types, especially those that do not support POSIX. Bash is one of them. This is why the error message contained "Bad for loop variable".

    
16.06.2018 / 19:23