November 2015
Beginner
282 pages
5h 5m
English
Now we know how to write a simple hello world shell script. Next, we will be getting familiar with variables in shell and how to define and use variables in shell.
A variable name can be a combination of alphanumeric and underscore. Also, the name of the variable can't start with a number. The variable names in shell script are case-sensitive. Special characters, such as *, -, +, ~, ., ^, and so on, are not used in variable names because they have a special meaning in shell. The following table illustrates the correct and incorrect ways of naming a variable:
|
Correct variable names |
Incorrect variable names |
|---|---|
|
variable |
2_variable |
|
variable1 |
2variable |
|
variable_2 |
variable$ |
|
_variable3 |
variable*^ |