Variables
Assigning Variables
var=1
echo $var # var is the variable, $var is the value
N:B:
-
Do not confuse this with
=and-eq, whichtest, rather than assign! so ...var = 1won't work. Mind the Gap!!!
$ export foo="Hello, World"
$ bar="Goodbye"
$ echo $foo
Hello, World
$ echo $bar
Goodbye
$ bash
bash-3.2$ echo $foo
Hello, World
bash-3.2$ echo $bar
bash-3.2$
Shell Variables
| variable | Meaning |
|---|---|
$0 | |
$? | Exit code from last command |
$1 $2 $3 and so on | 1st 2nd 3rd parameters and so on |
$SHELL | The Shell |
$HOME | User Home directory |
$USER | Shell Username |
Shell Variable declaration
- declare
- export
- set
- let
- unset