construct
Bash arithmetic for loop
Bash-specific arithmetic loop; initializes once, tests before each body, then updates. Omitted test is treated as true. Returns last body command status or zero if no body runs, nonzero on invalid arithmetic expressions.
Formal Syntax & Structure
bash syntaxbash
for (( init; test; update )); do commands; doneReturn Value
exit status
Bash-specific arithmetic loop; initializes once, tests before each body, then updates. Omitted test is treated as true. Returns last body command status or zero if no body runs, nonzero on invalid arithmetic expressions.
Working Example
Example Snippetbash
count=3for (( i=0; i<count; i++ )); do printf '%s\n' "$i"doneprintf 'end=%s\n' "$i"