Variables
Creating Variables
In thebash shell, you do not need to declare variables explicitly. Variables can be created at
anypoint of time by simply assigning a value. A variable can be created without a value by
leaving the right-hand side of the assignment operator(=) blank. The syntax for creating a
variable is given below:
Syntax
<variable name>=<value>
variable, ensSure that there is no space on either side of the
Note: When you declare a
assignment operator.
a delimiter, such as an embedded space,
assign to a variable contains
f the value that you within either single or double quotes.
you need to enclose the value
Example
name-"John Lennon" any embedded
marks if the value does not have
quotation
iowever, you need not use the
spaces. characters. All the variables in
variables as integers or
cannot declare you can perform
Snell scripts, you treated as character strings. However
operating system are
aie Linux
aithmetic operations on variables.
Example
name=Paul
ctr=l variable contains a
ctr
contain a numeric variable. The and not the number 1.
ctr does not "1"
In the above example, contains the character
the ctr
variable 33
character string. Therefore,
Creating Variables
In thebash shell, you do not need to declare variables explicitly. Variables can be created at
anypoint of time by simply assigning a value. A variable can be created without a value by
leaving the right-hand side of the assignment operator(=) blank. The syntax for creating a
variable is given below:
Syntax
<variable name>=<value>
variable, ensSure that there is no space on either side of the
Note: When you declare a
assignment operator.
a delimiter, such as an embedded space,
assign to a variable contains
f the value that you within either single or double quotes.
you need to enclose the value
Example
name-"John Lennon" any embedded
marks if the value does not have
quotation
iowever, you need not use the
spaces. characters. All the variables in
variables as integers or
cannot declare you can perform
Snell scripts, you treated as character strings. However
operating system are
aie Linux
aithmetic operations on variables.
Example
name=Paul
ctr=l variable contains a
ctr
contain a numeric variable. The and not the number 1.
ctr does not "1"
In the above example, contains the character
the ctr
variable 33
character string. Therefore,