Sample Header Ad - 728x90

How can I create an arithmetic loop in a POSIX shell script?

30 votes
3 answers
15408 views
I know how to create an arithmetic for loop in bash. How can one do an equivalent loop in a POSIX shell script? As there are various ways of achieving the same goal, feel free to add your own answer and elaborate a little on how it works. An example of one such bash loop follows: #!/bin/bash for (( i=1; i != 10; i++ )) do echo "$i" done
Asked by Vlastimil Burián (30515 rep)
Dec 13, 2017, 01:10 PM
Last activity: Feb 7, 2022, 05:08 PM