Variables in bash seq replacement ({1..10}) [duplicate]

In bash, brace expansion happens before variable expansion, so this is not directly possible.

Instead, use an arithmetic for loop:

start=1
end=10
for ((i=start; i<=end; i++))
do
   echo "i: $i"
done

OUTPUT

i: 1
i: 2
i: 3
i: 4
i: 5
i: 6
i: 7
i: 8
i: 9
i: 10

Leave a Comment