How does the shell display the value of a variable?
In Shell, you can use the echo command to display the value of variables. Here are some examples:
- Display the value of the variable:
variable="Hello World"
echo $variable
Output: Hello World
- Display the value of a variable in a string printed out.
name="John"
echo "My name is $name"
Output: I am called John.
- Values of multiple variables:
name="John"
age=25
echo "My name is $name and I am $age years old"
Output: I am 25 years old and my name is John.
Please note that you can reference the value of a variable by adding the $ symbol before the variable.