mindthump icon

Bash special shell variables

mindthump | PRO | 08/29/21 05:53:46 PM UTC (Edited) | 0 ⭐ | 721 👁️ | Never ⏰ | []
Bash |

670 B

|

None

|

0 👍

/

0 👎

Variable    Meaning
--------    -------
$0          Filename of script
$1 - $9     Positional parameters #1 - #9
${10}       Positional parameter #10
$#          Number of positional parameters
${#*}       Number of positional parameters
${#@}       Number of positional parameters
"$*"        All the positional parameters (as a single word) *
"$@"        All the positional parameters (as separate strings)
$?          Return value
$$          Process ID (PID) of script
$-          Flags passed to script (using set)
$_          Last argument of previous command
$!          Process ID (PID) of last job run in background
 
* Must be quoted, otherwise it defaults to $@.

Comments