The bash shell lets you put multiple commands on one line if they are each separated by a semicolon ( ; ). So in the above for loop, you can see that bash consideres considers the do keyword to start a separate command. Two alternate ways of writing the loop are: Code Block |
---|
| # One line for each clause, no semicolons
for <variable name> in <expression>
do
<something>
<something else>
done |
Code Block |
---|
| # All on one line, with semicolons separating clauses
for <variable name> in <expression>; do <something>; <something else>; done |
|