echo
by itself displays a line of text. It will take any thing within the following "..."
two quotation marks, literally, and just print out as it is. However with echo -e
you're making echo
to enable interpret backslash escapes. So with this in mind here are some examples
INPUT: echo "abc\n def \nghi"
OUTPUT:abc\n def \nghi
INPUT: echo -e "abc\n def \nghi"
OUTPUT:abc
def
ghi
Note: \n
is new line, ie a carriage return. If you want to know what other sequences are recognized by echo -e
type in man echo
to your terminal.
echo -e
is not defined by POSIX and probably varies by shell. – jordanm Mar 12 '15 at 18:28man echo
to read the manual forecho
. – nanny Mar 12 '15 at 18:51echo -e
behaves different thanecho
) - which are the default set of programs on all the popular distros like Ubuntu / Debian / CentOS / Arch. That said,man echo
is the best answer if they're unsure about their particular distribution. – AmphotericLewisAcid Apr 18 '23 at 20:09