Artificial intelligent assistant

Why isn't there a ";" after "do" in sh loops? Why isn't there a `;` character after `do` in shell loops when written on a single line? Here's what I mean. When written on a multiple lines, a `for` loop looks like: $ for i in $(jot 2) > do > echo $i > done And on a single line: $ for i in $(jot 2); do echo $i; done All the collapsed lines get a `;` after them _except_ for the `do` line, and if you include the `;`, it is an error. Someone probably a heck of a lot smarter than me decided that this was the right thing to do for a reason, but I can't figure out what the reason is. It seems inconsistent to me. The same with `while` loops too. $ while something > do > anotherthing > done $ while something; do anotherthing; done

That is the syntax of the command. See Compound Commands


for name [ [in [words …] ] ; ] do commands; done


Note specifically: `do commands`

Most people put the `do` and `commands` on a separate line to allow for easier readability but it is not necessary, you could write:


for i in thing
do something
done


I know this question is specifically about shell and I have linked to the bash manual. It is not written that way in the shell manual but it is written that way in an article written by Stephen Bourne for byte magazine.

Stephen says:

> A _command list_ is a sequence of one or more simple commands separated or terminated by a newline or `;` (semicolon). Furthermore, reserved words like _do_ and _done_ are normally preceded by a newline or `;`... In turn each time the command list following _do_ is executed.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d2aa7712abcfce5de8e528ed264a72de