First page Back Continue Last page Graphics

Some Variable Examples

declare -ai myArray # numeric array

declare -r pi=3.1415926 # constant float

readonly maxsize=99 # constant integer

declare my_string='x' # local string

local anotherString # local string

declare -i len=0 # local integer

declare -ix DEPTH=37 # global integer

You can use the $ operator (or ${...})and the echo command to inspect these:

echo "pi is $pi and maxsize is ${maxsize}"

Note that the variable pi above is actually a string, and not a number. If you try to use it as a number, it will produce an invalid operator error for the '.'.