How can I use variables with echo?

0195

You can use variables with the echo command in Bash by first defining a variable and then referencing it. Here's a simple example:

# Define a variable
greeting="Hello LabEx"

# Use echo to print the variable
echo $greeting

In this example:

  • greeting is a variable that holds the string "Hello LabEx".
  • When you use echo $greeting, it prints the value of the variable.

Make sure to use the $ sign before the variable name to reference its value. If you have any more questions or need further examples, let me know!

0 Comments

no data
Be the first to share your comment!