Shell scripingby harsha

 Important points only:

  • Variables in shell can be accessed by below 3 ways:
echo $A

echo ${A}

echo "${A}"

  • If you want variable subsitution in string use double quotes, single quotes will not substiute value it will print symbol itself

❯ echo "Value of a is ${A}"

Value of a is 100

❯ echo 'Value of a is ${A}'

Value of a is ${A}


  • The ‘-e‘ option in Linux acts as an interpretation of escaped characters that are backslashed.

Using option ‘\b‘ – backspace with backslash interpretor ‘-e‘ which removes all the spaces in between.
$ echo -e "Tecmint \bis \ba \bcommunity \bof \bLinux \bNerds" 

TecmintisacommunityofLinuxNerds 

Using option ‘\n‘ – New line with backspace interpretor ‘-e‘ treats new line from where it is used.

$ echo -e "Tecmint \nis \na \ncommunity \nof \nLinux \nNerds" 

Tecmint 
is 
a 
community 
of 
Linux 
Nerds 






Comments