var in bash code example
Example 1: definition varibale in bash
fullname='Restu Wahyu Saputra'
echo $fullname
Example 2: bash create variable
name="Lance Armah"
Example 3: assign a variable in bash
echo
a=879
echo "The value of \"a\" is $a."
let a=16+5
echo "The value of \"a\" is now $a."
echo
echo -n "Values of \"a\" in the loop are: "
for a in 7 8 9 11
do
echo -n "$a "
done
echo
echo
echo -n "Enter \"a\" "
read a
echo "The value of \"a\" is now $a."
echo
exit 0
Example 4: print variable in bash
echo
echo "When single quote is used with string:"
invitation='Welcome to javatpoint'
echo $invitation
echo
echo "When double quote is used with string:"
invitation="Welcome to javatpoint"
echo $invitation
echo
echo "When variable is used with double quote:"
Remark="Hello User!, $invitation"
echo $Remark
echo
echo "When variable is used with single quote:"
Remark='Hello User!, $invitation'
echo $Remark
echo