keyword
Bash for loop
Iterates once per expanded word, or positional argument when in is omitted. Returns the last executed command status or zero if no iteration runs.
Formal Syntax & Structure
bash syntaxbash
for name [in words ...]; do commands; doneParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | identifier | Loop variable. |
| words | word list | Expanded items; omitted uses positional arguments. |
Return Value
exit status
Iterates once per expanded word, or positional argument when in is omitted. Returns the last executed command status or zero if no iteration runs.
Working Example
Example Snippetbash
for item in 'daily report' '' backup; do printf '[%s]\n' "$item"done