Variables
Variables are the containers which store data or a useful piece of information as the value inside them.
Variable-name="Variable-value"
Set variable name="DevOps"
#!/bin/bash
# Variable set
name=”DevOps”
# Print value
echo “$name”
Variable is known as the temporary storage for any kind of data like integer, float, char, etc.
A variable name can include alphabets, digits, and underscore, and its name can be started with alphabets and underscore only.
System Variables
These are the pre-defined variables as they are created and maintained by the LINUX operating system itself.
Their standard convention is that generally they are defined in capital letters, i.e., UPPER_CASE.
So whenever you see a variable defined in upper cases, most likely, they are the system-defined variables.
$PWD
Sample Script
#!/bin/bash
echo $HOME
echo “$HOSTNAME”
echo “$UID”
Export Variables
export command makes the variable available to all the subsequent commands executed in that shell.
export name=”devops”
Sample Script
It changes your terminal name into DevOps Engineer.
export ps1=”DevOps Engineer$”
Last updated