4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / bin / sh / bltin / echo.1
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Kenneth Almquist.
.\" Copyright 1989 by Kenneth Almquist
.\"
.\" %sccs.include.redist.roff%
.\"
.\" @(#)echo.1 8.1 (Berkeley) %G%
.\"
.Dd
.Dt ECHO 1
.Os BSD 4.4
.Sh NAME
.Nm echo
.Nd produce message in a shell script
.Sh SYNOPSIS
.Nm echo
.Op Fl n | Fl e
.Ar args...
.Sh DESCRIPTION
.Nm Echo
prints its arguments on the standard output, separated by spaces.
Unless the
.Fl n
option is present, a newline is output following the arguments.
The
.Fl e
option causes
.Nm echo
to treat the escape sequences specially, as described in the following
paragraph.
The
.Fl e
option is the default, and is provided solely for compatibility with
other systems.
Only one of the options
.Fl n
and
.Fl e
may be given.
.Pp
If any of the following sequences of characters is encountered during
output, the sequence is not output. Instead, the specified action is
performed:
.Bl -tag -width indent
.It Li \eb
A backspace character is output.
.It Li \ec
Subsequent output is suppressed. This is normally used at the end of the
last argument to suppress the trailing newline that
.Nm echo
would otherwise output.
.It Li \ef
Output a form feed.
.It Li \en
Output a newline character.
.It Li \er
Output a carriage return.
.It Li \et
Output a (horizontal) tab character.
.It Li \ev
Output a vertical tab.
.It Li \e0 Ns Ar digits
Output the character whose value is given by zero to three digits.
If there are zero digits, a nul character is output.
.It Li \e\e
Output a backslash.
.El
.Sh HINTS
Remember that backslash is special to the shell and needs to be escaped.
To output a message to standard error, say
.Pp
.D1 echo message >&2
.Sh BUGS
The octal character escape mechanism
.Pq Li \e0 Ns Ar digits
differs from the
C language mechanism.
.Pp
There is no way to force
.Nm echo
to treat its arguments literally, rather than interpreting them as
options and escape sequences.