Bash Variables
Written by anil on July 9th, 2007 in Bash Scripting, Linux.
General method for assigning variables in bash is, name of the varaible, an equal sign then varaible value. Keep in mind don't put space on either side of equal sign. Another point is, you can assign any values to a varible. No need of declearaing the variable type. See the examples. You will understand what I mean.
$ INT=123
$echo $123
$ 123
$ STRING=Anil
$ echo $STRING
$ Anil
But if you needed, you can declare variable types or limit value assignment to varaibles using the bash builtin command "declare".
Syntax
declare option(s) VARIABLE=value
The common options are,
-a an array. (YES BASH has arrays)
-i an integer.
-r readonly (constant)
More to come …
Subscribe to my feed … SUBSCRIBE
Thanks