You can use variables with the echo command in Linux by referencing the variable with a dollar sign ($). Here’s how to do it:
Steps:
Declare a Variable:
my_variable="Hello LabEx"Use
echoto Display the Variable:echo $my_variable
Example:
my_variable="Hello LabEx"
echo $my_variable
Output:
Hello LabEx
Notes:
- If the variable name is followed by characters that could be part of a variable name, enclose it in curly braces:
echo ${my_variable}World # Outputs: Hello LabExWorld
Using variables with echo is a great way to display dynamic content in your scripts. If you have more questions or need further examples, let me know!
