1. Home
  2. Bash
  3. Bash Tutorial
  4. Bash – Variables

Bash – Variables

Variables in Bash

The bash variables are the same as other programming languages. You don’t need to specify the type of variable in bash scripting. Read below example.

#!/bin/bash

NAME="TecAdmin Tutorials"
echo $NAME

launchdate="Feb 08, 2013"
echo $launchdate

Global vs Local Variables

Global variables are accessible anywhere in the script. Where Local variables are accessible in scope only. For example, a variable that is used inside a function only.

System Variables

System variables are responsible to define the aspects of the shell. These variables are maintained by bash itself. But we can modify these variables to change shell aspects.

Type env on bash shell to print all the available variables with there value.

$ env

Generally, these variables are defined in capital letters. For example PATH, SHELL, HOME, LANG, PWD and many more.

Tags , ,