November 2005
Beginner to intermediate
528 pages
24h 11m
English
Preface a variable by a dollar sign ($) to reference its value. You can also optionally enclose it in braces ({ }). You can assign a value to a variable through an equals sign (=) with no whitespace on either side of it:
$ TMP=temp.file
By default, variables are seen only within the shell itself; to pass variables to other programs invoked within the shell, see the export built-in command.
If followed by an index enclosed by brackets ([ ]), the variable is considered an array variable. For instance:
$ DIR_LIST[0]=src
$ DIR_LIST[1]=headers
$ ls ${DIR_LIST[1]}The contents of headers are listed. Many substitutions and commands in this chapter handle arrays by operating on each element separately.
Read now
Unlock full access