You got it! Labby is happy to show you more echo examples involving variables.
First, let's create a variable. You can think of a variable as a named container that holds a value.
-
Define a variable:
NAME="Labby"This command creates a variable named
NAMEand assigns the string "Labby" to it. -
Echo the variable: To display the value stored in the
NAMEvariable, you use a dollar sign ($) before the variable name:echo "Hello, my name is $NAME."You should see:
Hello, my name is Labby.The shell replaces
$NAMEwith its actual value beforeechodisplays the string. -
Another variable example:
CITY="Techville" echo "I live in $CITY."Output:
I live in Techville.
Why is this useful?
It helps to make your commands and scripts more dynamic. Instead of typing the same information repeatedly, you can store it in a variable and reuse it.
Go ahead and try these examples in your terminal! Feel free to create your own variables and echo them. Let me know if you have any other questions!