Quick Answer: How Do I Print a Variable Value in Linux?

Quick Answer: How Do I Print a Variable Value in Linux?
Contents

How do you print the value of a variable in Linux?

Sh, Ksh, or Bash shell user type the set command. Csh or Tcsh user type the printenv command.

How do you print a variable value in Unix?

To Print the value of above variables, use echo command as shown below :

  1. # echo $HOME. # echo $USERNAME.
  2. $ cat myscript.
  3. #!/bin/bash. # display user information from the system. …
  4. $ echo “The cost of the item is $15” …
  5. $ echo “The cost of the item is $15” …
  6. var1=10. …
  7. $ cat test3. …
  8. Running the script produces the following output:
Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.