Linux Commands - echo (print output)
by
Jeremy Canfield |
Updated: January 26 2021
| Linux Commands articles
The echo and printf commands are used to print text. In this example, the echo command is used to print Hello World.
echo "Hello World"
Escape back slashes
By default, the echo command will print back slashes.
~]# echo "Hello\tWorld"
Hello\tWorld
The -e option can be used to escape back slashes. In this example, by escaping back slash, \t is properly interpreted as a tab.
~]# echo -e "Hello\tWorld"
Hello World
In this example, \n is properly interpreted as a new line.
~]# echo -e "Hello\nWorld"
Hello
World
Do not print new line
The -n option can be used to not print a new line at the end of the output.
~]# echo -n "Hello World"
Did you find this article helpful?
If so, consider buying me a coffee over at