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.
Variables in Linux Shell Scripting
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!
Related posts:
- Shell Scripting Introduction
- Shell Syntax
- Shell - Strings
- Shell - Variables
- Shell - User Intraction
- First Shell Script
- Shell - Arithmetics
- Shell - Case Statement
- Shell - Command Line Arguments
- Shell - For Loop
- Shell - While Loops
- Shell - IF Statements
- Shell - Input Output Redirections
- Shell - Pipes and Filters
- Shell - Process Management
Your IP address1 is: 172.18.0.2
Tutorials
Latest Updates
Follow us
- Tech-Tutorials twitter.com/techcuriosity