-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2051
koalaman edited this page Mar 11, 2014
·
10 revisions
for i in {1..$n}
do
echo "$i"
done
for ((i=0; i<n; i++))
do
echo "$i"
done
In Bash, brace expansion happens before variable expansion. This means that brace expansion will never account for variables.
Use an arithmetic for loop instead.
None (if you're writing for e.g. zsh, make sure the shebang indicates this so shellcheck won't warn)