FreeKB - Linux Commands echo (print output)
Linux Commands - echo (print output)

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"

 



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 be9d3 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |