According to convention it should be in all caps
Variable names cannot start with digits
There shouldn’t be any space between the variable name, = sign and the value
NAME_01="David"
SPORT="Foot"
echo "My name is $NAME_01"
The {}
is used to make the command inside it be executed first and its value is used in place of the {}
echo "The best sport is {$SPORT}ball"
foo=bar
echo $foo (bar)
NOTE
- Shell commands are space sensitive
foo = bar
will throw error- Shell thinks that you are trying to call a function called foo with parameters = and bar
# ${string: offset: length}
number = 12313.12
${number:0:4}
# 1231
Double Quotes vs. Single Quotes
Double Quotes the string is expanded
echo "Value : $foo"
# Value : bar
The String is not expanded with single quotes
echo 'Value : $foo'
# Value : $foo