You might have heard of echo
as the command to “print lines.” Technically it emits each of the arguments in turn, separated by a space character, and prints a single newline at the end. Let’s explore this with some examples.
1
$ echo "It’s pitch black. You’re likely to be eaten by a grue."
2
It’s pitch black. You’re likely to be eaten by a grue.
3
$ █
As you can see the cursor appears on a new line below the output. Since the prompt does not contain a newline, that newline must be part of the output of echo
. We can confirm this by printing the output character representations:
This page is a preview of The newline Guide to Bash Scripting
- echo
Contents