Search⌘ K

Declaration Mechanism: Special Parameters

Understand how Bash declares and uses special parameters to manage positional arguments, command exit statuses, and process IDs. Learn how to manipulate these parameters within scripts, including replacing specific positional parameters using the set command.

We'll cover the following...

Special parameters

Bash declares special parameters and assigns values to them. It handles them the same way as it does shell variables.

Special parameters pass information from the shell to the launched application, and vice versa. A positional parameter is an example of this kind of Bash variable.

Special parameters

The following table shows frequently used special parameters.

Name Value
$* The string with all positional parameters passed to the script. Parameters start with the $1 variable but not with $0. If we skip the double quotes ($*), Bash inserts each positional parameter as a separate word. With double quotes ("$*"), Bash handles it as one quoted string.
...