misc cleanup
[unix-history] / usr / src / bin / sh / bltin / echo.1
CommitLineData
d1b73048
KB
1.\" Copyright (c) 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
4f637f59
KB
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Kenneth Almquist.
8aaff48c 6.\" Copyright 1989 by Kenneth Almquist
4f637f59 7.\"
8aaff48c 8.\" %sccs.include.redist.roff%
4f637f59 9.\"
cbfe5a6d 10.\" @(#)echo.1 8.2 (Berkeley) %G%
4f637f59 11.\"
8aaff48c
CL
12.Dd
13.Dt ECHO 1
14.Os BSD 4.4
15.Sh NAME
16.Nm echo
17.Nd produce message in a shell script
18.Sh SYNOPSIS
19.Nm echo
20.Op Fl n | Fl e
21.Ar args...
22.Sh DESCRIPTION
23.Nm Echo
4f637f59
KB
24prints its arguments on the standard output, separated by spaces.
25Unless the
8aaff48c 26.Fl n
4f637f59
KB
27option is present, a newline is output following the arguments.
28The
8aaff48c 29.Fl e
4f637f59 30option causes
8aaff48c 31.Nm echo
4f637f59 32to treat the escape sequences specially, as described in the following
8aaff48c
CL
33paragraph.
34The
35.Fl e
4f637f59
KB
36option is the default, and is provided solely for compatibility with
37other systems.
38Only one of the options
8aaff48c 39.Fl n
4f637f59 40and
8aaff48c 41.Fl e
4f637f59 42may be given.
8aaff48c 43.Pp
4f637f59
KB
44If any of the following sequences of characters is encountered during
45output, the sequence is not output. Instead, the specified action is
46performed:
8aaff48c
CL
47.Bl -tag -width indent
48.It Li \eb
4f637f59 49A backspace character is output.
8aaff48c 50.It Li \ec
4f637f59
KB
51Subsequent output is suppressed. This is normally used at the end of the
52last argument to suppress the trailing newline that
8aaff48c 53.Nm echo
4f637f59 54would otherwise output.
8aaff48c 55.It Li \ef
4f637f59 56Output a form feed.
8aaff48c 57.It Li \en
4f637f59 58Output a newline character.
8aaff48c 59.It Li \er
4f637f59 60Output a carriage return.
8aaff48c 61.It Li \et
4f637f59 62Output a (horizontal) tab character.
8aaff48c 63.It Li \ev
4f637f59 64Output a vertical tab.
8aaff48c 65.It Li \e0 Ns Ar digits
4f637f59
KB
66Output the character whose value is given by zero to three digits.
67If there are zero digits, a nul character is output.
8aaff48c 68.It Li \e\e
4f637f59 69Output a backslash.
8aaff48c
CL
70.El
71.Sh HINTS
4f637f59
KB
72Remember that backslash is special to the shell and needs to be escaped.
73To output a message to standard error, say
8aaff48c
CL
74.Pp
75.D1 echo message >&2
76.Sh BUGS
77The octal character escape mechanism
78.Pq Li \e0 Ns Ar digits
79differs from the
4f637f59 80C language mechanism.
8aaff48c 81.Pp
4f637f59 82There is no way to force
8aaff48c 83.Nm echo
4f637f59
KB
84to treat its arguments literally, rather than interpreting them as
85options and escape sequences.