Produce output using the ECHO command in Linux

Home > Search > Linux commands
  by

The echo command can be used to produce text. In this example, the echo command is used to print Hello World.

~]# echo "Hello World"
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"

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments