Bash - Special variables
|
|
|
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