xref: /original-bsd/bin/sh/bltin/echo.1 (revision b3c06cab)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Kenneth Almquist.
6.\" Copyright 1989 by Kenneth Almquist
7.\"
8.\" %sccs.include.redist.roff%
9.\"
10.\"	@(#)echo.1	8.2 (Berkeley) 05/04/95
11.\"
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
24prints its arguments on the standard output, separated by spaces.
25Unless the
26.Fl n
27option is present, a newline is output following the arguments.
28The
29.Fl e
30option causes
31.Nm echo
32to treat the escape sequences specially, as described in the following
33paragraph.
34The
35.Fl e
36option is the default, and is provided solely for compatibility with
37other systems.
38Only one of the options
39.Fl n
40and
41.Fl e
42may be given.
43.Pp
44If any of the following sequences of characters is encountered during
45output, the sequence is not output.  Instead, the specified action is
46performed:
47.Bl -tag -width indent
48.It Li \eb
49A backspace character is output.
50.It Li \ec
51Subsequent output is suppressed.  This is normally used at the end of the
52last argument to suppress the trailing newline that
53.Nm echo
54would otherwise output.
55.It Li \ef
56Output a form feed.
57.It Li \en
58Output a newline character.
59.It Li \er
60Output a carriage return.
61.It Li \et
62Output a (horizontal) tab character.
63.It Li \ev
64Output a vertical tab.
65.It Li \e0 Ns Ar digits
66Output the character whose value is given by zero to three digits.
67If there are zero digits, a nul character is output.
68.It Li \e\e
69Output a backslash.
70.El
71.Sh HINTS
72Remember that backslash is special to the shell and needs to be escaped.
73To output a message to standard error, say
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
80C language mechanism.
81.Pp
82There is no way to force
83.Nm echo
84to treat its arguments literally, rather than interpreting them as
85options and escape sequences.
86