Bash Command: echo

echo

The next command echo simply prints out a message to the Bash shell’s Standard Output (STDOUT). An echo statement is very similar to the print() method in Python3, or the console.log() method in JavaScript, or the System.out.println() method in Java. View the following code snippets to see how you can display “hello” using Python, JavaScript, Java, and the Bash echo command.

print("Hello")
> console.log("Hello")
System.out.println("Hello")
echo "Hello"

To use the echo command we simply need to invoke the command with one argument that results in a string.

Enter echo "Hello world".

echo “hello world”

Note

echo commands are especially useful inside of Bash scripts. In any given Bash script many things may be happening and outputting some message to the individual that invokes the script is a very useful feature.

The echo command can be used to easily view the contents of a Shell Variable. Your home directory, path, and many other variables are attached directly to your Bash Shell in the form of variables. You can use echo $VARIABLE to easily view the contents of the variable.