Hands-on variable assignment

Open a new blank file and add the following to it:

#!/bin/bashPI=3.14VAR_A=10VAR_B=$VAR_AVAR_C=${VAR_B}echo "Let's print 3 variables:"echo $VAR_Aecho $VAR_Becho $VAR_Cecho "We know this will break:"echo "0. The value of PI is $PIabc"     # since PIabc is not declared, it will be empty stringecho "And these will work:"echo "1. The value of PI is $PI"echo "2. The value of PI is ${PI}"echo "3. The value of PI is" $PIecho "And we can make a new string"STR_A="Bob"STR_B="Jane"echo "${STR_A} + ${STR_B} equals Bob + Jane"STR_C=${STR_A}" + "${STR_B}echo "${STR_C} is the same as Bob + Jane too!"echo "${STR_C} + ${PI}"exit 0
Notice the nomenclature. It is great to use a standardized mechanism to name variables, but to use 

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.