DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

echo(C)


echo -- echo arguments

Syntax

echo [ -n ] [ arg ... ]

Description

The echo command writes its arguments separated by blanks and terminated by a new line on the standard output. The -n option prints a line without the newline; this is the same as using the ``\c'' escape sequence if it is placed at the end of the list of arguments. However, POSIX.2 and the X/Open CAE Specification, Commands and Utilities, Issue 4, 1992 do not support the -n option, so if you are using /bin/posix/echo rather than /bin/echo, the newline will always be printed. In this case, it may be suppressed using the printf(C) command.

echo also understands C-like escape conventions; beware of conflicts with the shell's use of ``\'':


\a
alert character (for example, ASCII BEL)

\b
backspace

\c
ignore all subsequent arguments, and do not output a newline

\f
form-feed

\n
new line

\r
carriage return

\t
tab

\v
vertical tab

\\
backslash

\0n
The 8-bit character whose ASCII code is a 0, 1, 2 or 3-digit octal number n. To prevent the argument being quoted literally, it must be escaped from the shell. For example:

echo '\065'
echoes the number ``5''

echo \\0101
echoes the letter ``A''
For the octal equivalents of each character, see ascii(M).

The echo command is useful for producing diagnostics in command files and for sending known data into a pipe.

A version of this command is built into ksh(C) and sh(C).

Examples

When representing an 8-bit character by using the escape convention \0n, the octal number n must always be preceded by the digit zero (0).

For example, typing: echo "WARNING:\07" will print the phrase ``WARNING:'' and sound the ``bell'' on your terminal. The use of single (or double) quotes (or two backslashes) is required to protect the ``\'' that precedes the ``07''.

Limitations

The version of echo built into csh(C) only supports the escape sequences ``\c'' and ``\n''.

See also

ascii(M), csh(C), ksh(C), sh(C)

Standards conformance

echo is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003