dollar zero
The special parameter $0, which holds the name the current shell or script was started as.
In more detail
At the prompt it prints something like -bash or bash, and in a script it holds the path used to run the script. It reports the invoked name, so a program started through a link or as sh shows that name rather than the real program. Use it in usage messages so they name the script correctly.
Example
echo "$0"Related terms
- positional parameters — The numbered variables $1, $2 and so on that hold the arguments given to a script or function, with $# holding how many there are.
- login shell — The shell your account starts when you log in, recorded in the user database and shown by the SHELL variable.
- usage message — A short line a script prints to standard error when it is called wrongly, showing how it should be run.
Taught in
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation