
Variable:
There are two types of variables namely:
i) Local Variable (shell variable)
ii) Environment Variable
SHELL VARIABLES:
Shell allows you to define and use variable.
If you want to define a variable a with numerical value 10.
You can do so by typing the following at the shell prompt:
user1@ wtutopc ~]$ a=10
(there must not be any space before and after = sign)
user1@ wtutopc ~]$ echo $a
(show the value of variable a, if you don’t precede a with $ sign, the command will just display the character a)
user1@wtutopc ~]$ b= “Hello, this is wali”
user1@wtutopc ~]$ echo $b
NOTE: See use of quotes in 13.7.2(inhibiting expansion with quotes)
[root@wtutopc ~]# mkdir –p wali/dir1
[root@wtutopc ~]# path=”/root/wali/dir1”
[root@wtutopc ~]# cd $path
[root@wtutopc dir1]# touch file{1,2,3}
[root@wtutopc dir1]# cd
[root@wtutopc ~]# ls $path
Note: Shell variables are local to a single shell by default;
Whereas Environment variables are not limited to a single shell.





