Receive all updates via Facebook. Just Click the Like Button Below

Shell Variables

In Linux (Shell), there are two types of variable:
(1) System variables - Created by Linux developers ( inbuild variables ).
These variables are defined in UPPER case.
(2) User defined variables (UDV) - Created by user.
These variables are defined in lower case.

1

Variables in Linux Shell Scripting

2

System Variables
To see the system variables try the command: # set
To print the system variables use echo:

Example:

 
#!/bin/bash
echo $HOME
            

User Defined Variables
How to define User defined variables (UDV)?
To define a User defined variables use the following syntax:
# variable name=value

How to access value of UDV?
Use a $ symbol to access

Lets try creating a User defined variable and accessing it.

 
#!/bin/bash
value=100
echo $value
            

Save the above script as udv.sh
chmod 755 udv.sh
./udv.sh

You will find 100 printed on the screen!

3

Related posts:

Advertise here

picture picture

Follow us

picture

- Tech-Tutorials twitter.com/techcuriosity

Like us

About Techcuriosity

I am Telson, the webmaster of Techcuriosity.com and through this site, I share my knowledge and curiosities in the Tech World.


What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch

    techcuriosity@gmail.com
    UK : +44 77 33 890 678

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture

    picture