Bash - Special variables

Wednesday, 10 August 2011 15:04

Bash special variables explained

Bash Special variables

The following table describes the variables you can use in your Bash scipt and the meaning associtated.

Special Shell Variables

Variable Description
$0 Filename of script
$1 Positional parameter #1
$2 - $9 Positional parameters #2 - #9
${10} Positional parameter #10
$# Number of positional parameters
"$*" All the positional parameters (as a single word) *
"$@" All the positional parameters (as separate strings)
${#*} Number of positional parameters
${#@} Number of positional parameters
$? 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�" $@ ".

On the same subject you can consule the article about the Bash File test operators

If you have any remark or questions feel free to put a comment.

If you enjoyed this tutorial and want to promote it don't hesitate to click on

Tags: process , parameters , positional , special , number , script , variables , bash , parameter , argument

Add comment


Security code
Refresh