Name

echo — stdin  stdout  - file  -- opt  --help  --version

Synopsis

echo [options] strings

The echo command simply prints its arguments:

echo We are having fun
We are having fun

OS X has several different echo commands with slightly different behavior. There’s /bin/echo, but shells typically override this with a built-in command called echo. To find out which you’re using, run the command type echo.

Useful options

-n

Don’t print a final newline character.

-e

Recognize and interpret escape characters. (Not supported by /bin/echo.) For example, try echo 'hello\a' and echo -e 'hello\a'. The first prints literally and the second makes a beep.

-E

Don’t interpret escape characters: the opposite of -e. (Not supported by /bin/echo.)

Available escape characters are:

\a

Alert (play a beep)

\b

Backspace

\c

Don’t print the final newline (same effect as -n)

\f

Form feed

\n

Line feed (newline)

\r

Carriage return

\t

Horizontal tab

\v

Vertical tab

\\

A backslash

\'

Single quote

\"

Double quote

\nnn

The character whose ASCII value is nnn in octal

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.