Echo vs printf
This page was last updated on April 4, 2012.
This is an observation of the behavior of echo vs printf when used on the command line. This behavior may not cause any issues when used inside a script.
- Echo does what you’d expect it to do:
-
user@computer:~$ echo HELLO HELLO user@computer:~$
- Printf lands inside my prompt:
-
user@computer:~$ printf HELLO HELLOuser@computer:~$
- To get printf to do what echo does takes the addition of the \n code for a newline:
-
user@computer:~$ printf "HELLO\n" HELLO user@computer:~$
Obligatory Happy Ending
And they all lived happily ever after. The end.

Comment: