Variables in Shell Script

Rules :

  • Variable name cannot start with a number

There are two types of variable :

  • System variables. (Example : $BASH) (Conventionally in all sCAPS)
  • User defined variables (Conventionally in small letters)
#! /bin/bash -x
# comments example
echo "Hello Inline Comment" # This is the inline comment
 
# 1st System Variables #capital variables are system variables Example $BASH
# 2nd User defined Variabled # small letters
# export 

echo $BASH   # System Variable
echo $BASH_VERSION
echo $SHELL

echo ----------------


name=Tyson
echo The name is $name
echo Home directory is $HOME

Reference :

Common Environment Variables

Leave a Comment