This fails:
#!/bin/bash
N_TIMES="$1"
for ((n = 0; n < $N_TIMES; n++)); do
# command
done
Setting the variable manually also fails:
#!/bin/bash
N_TIMES=10
for ((n = 0; n < $N_TIMES; n++)); do
# command
done
Both return:
Syntax error: Bad for loop variable
Why isn't the loop able to read the variable as a number for iteration? How should it be to be able to read the first argument as the number of times to run the command?