; mean in single line scripts like this:
while true; do sudo -n true; sleep 60; kill -0 '$$' || exit; done 2>/dev/null &
Does it mean new line, or "next command"?
It's a separator of commands. Though in the first instance, it might be better to think of it as ending the
For example, if you wanted to do a loop while some command returns success, you would do something like
while test -f /foo; do some_command; done`
The semicolon is used to indicate the end of the arguments to
test. Otherwise it would think that
do is another argument to
However you can use newlines instead of the semicolon. The following would be exactly equivalent to the example above, just without any semicolons
while test -f /foo do some_command done
In fact with bash, if you run the above command, and then after it finishes (or you CTRL+C it), if you go back in history (up arrow keys or whatnot), you'll notice it replaces the multi-line command with one using semicolons instead.
So yes, the syntax for things like
while break normal shell behavior.
I've personally always thought the syntax is weird, as the
do looks strange. But you get used to it.