I would like to know if there is any man page documenting the construction of the most basic script commands like if/then/else
, while
, for each
, and all the relative switches, like -eq
, -e
, -ge
, and so on.
Shell – if/then/else man page
documentationmanscriptingshell
Best Answer
You have to look at the manual for the specific shell you are using as the exact syntax for using these constructs can vary between shells. Most likely you are using
bash
, so you would doman bash
. Although there are many cases where you might be using something else. For example many distros use aPOSIX
shell for boot scripts (eg Debian usesdash
) or a least usebash
inPOSIX
compliant mode. Usually you can doman sh
to get the documentation in this case (this will be linked to the man page for the shell used if it is not the originalsh
or Bourne shell).If you are unsure which shell you are using, see this question - determine shell in script during runtime
Another thing work mentioning is the
help
builtin for bash, it gives an abbreviated version of what is in the manual for the various builtin commands/flow control statements etc. You can usehelp
on its own to see a full list of what is available, otherwise you can try things likehelp if
,help for
,help test
andhelp [
.