Linux and Unix echo command

Quick links

About echo
Linux and Unix main page

About echo

echo displays a line of text.


echo [SHORT-OPTION]... [STRING]...


-n do not output the trailing newline.
-e enable interpretation of backslash escapes.
-E disable interpretation of backslash escapes (default).
--help display a help message and exit.
--version output version information and exit.

If -e is in effect, the following sequences are recognized:

\\ backslash
\a alert (BELL)
\b backspace
\c produce no further output.
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\0NNN byte with octal value NNN (1 to 3 digits)
\xHH byte with hexadecimal value HH (1 to 2 digits)

NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


echo Hello world

Outputs the following text:

Hello world
echo * | wc

Displays the number of files (and directories) in the current directory. It accomplishes this by piping the output of the echo command to the wc command, which simply counts the words in the output of echo.

Related commands