echo Linux Command
echo Linux Command
Linux echo command with examples. The echo command is used to display information on the computer screen. We can use this command to display strings or values of variables. This command is widely used in shell scripts.
echo command Examples
A simple example of the echo command to display Hello world string to the screen.
$ echo Hello World
Hit Enter button to execute the command.
To use escape sequences in the strings, we can use -e command line option. For example, \n to denote new line.
Check out the output of the below command:
$ echo -e “Hello\nWorld”
Display Environment variables
We can use the echo command to display the values of the variables to the screen. For example, to display the environment variables to the screen.
echo command to know the SHELL variable on the system.
$ echo $SHELL
PATH
echo command to know the PATH environment variable. Type the following echo command with $PATH variable and press Enter button.
$ echo $PATH
The PATH environment variable is a list of directories that contain executable commands.
JAVA_HOME example
Let’s say we want to know the JDK install directory. We can use the echo command to display the JAVA_HOME variable. This variable points to the Java home directory. We need to set this variable during the JDK installation process.
$ echo $JAVA_HOME
The command accepts command line switches. To know full list of the command line switches, type
$ man echo
–
Linux Basic Commands Tutorial page:
https://www.testingdocs.com/linux-basic-commands-tutorial/
More Information on Ubuntu Linux:
https://ubuntu.com/