Shell Variables

Contents

Shell Variables#

The Bourne Again Shell and any other shells support the use of variables. The basic usage of variables is very simple. They do not need to be declared upfront and can just defined by an assignment. To reference a variable (i.e. use its value) a $ symbol has to be prepended. The name of a variable has to start with a letter and may contain numbers and underscores. Often uppercase names are used.

A=123
echo $A
123

A=abc
echo $A
abc

MY_VAR1="some string with spaces"
MY_VAR2=    

Index#