Reputation: 313
When i'm using for
like
for i in 1 2 3 4 5
then my file contains
#!/bin/sh
at the top
But when i'm using for(( i = 0; i<=5; i++))
then it is showing error
Syntax error: Bad for loop variable
and running properly when I remove shebang.
Please tell me the reason behind this.
Upvotes: 1
Views: 241
Reputation: 785156
You need to run with BASH, so use BASH shebang:
#!/bin/bash
Since this arithmetic BASH loop syntax
isn't supported in older bourne shell
:
for ((i = 0; i<=5; i++)); do
echo "$i"
done
Upvotes: 5