xref: /netbsd-src/bin/sh/bltin/echo.1 (revision 01869ca4d24a86379a68731bf9706a9f0820fe4e)
1*01869ca4Swiz.\"	$NetBSD: echo.1,v 1.14 2017/07/03 21:33:24 wiz Exp $
249f0ad86Scgd.\"
305a9db8eSjtc.\" Copyright (c) 1991, 1993
405a9db8eSjtc.\"	The Regents of the University of California.  All rights reserved.
561f28255Scgd.\"
661f28255Scgd.\" This code is derived from software contributed to Berkeley by
761f28255Scgd.\" Kenneth Almquist.
805a9db8eSjtc.\" Copyright 1989 by Kenneth Almquist
961f28255Scgd.\"
1061f28255Scgd.\" Redistribution and use in source and binary forms, with or without
1161f28255Scgd.\" modification, are permitted provided that the following conditions
1261f28255Scgd.\" are met:
1361f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
1461f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
1561f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1661f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1761f28255Scgd.\"    documentation and/or other materials provided with the distribution.
18b5b29542Sagc.\" 3. Neither the name of the University nor the names of its contributors
1961f28255Scgd.\"    may be used to endorse or promote products derived from this software
2061f28255Scgd.\"    without specific prior written permission.
2161f28255Scgd.\"
2261f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2361f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2461f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2561f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2661f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2761f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2861f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2961f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3061f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3161f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3261f28255Scgd.\" SUCH DAMAGE.
3361f28255Scgd.\"
3449f0ad86Scgd.\"	@(#)echo.1	8.1 (Berkeley) 5/31/93
35346aa5ddScgd.\"
3605a9db8eSjtc.Dd May 31, 1993
3705a9db8eSjtc.Dt ECHO 1
38f1247650Sgarbled.Os
3905a9db8eSjtc.Sh NAME
4005a9db8eSjtc.Nm echo
4105a9db8eSjtc.Nd produce message in a shell script
4205a9db8eSjtc.Sh SYNOPSIS
432b0a187fSchristos.Nm
4405a9db8eSjtc.Op Fl n | Fl e
4505a9db8eSjtc.Ar args ...
4605a9db8eSjtc.Sh DESCRIPTION
472b0a187fSchristos.Nm
4861f28255Scgdprints its arguments on the standard output, separated by spaces.
4961f28255ScgdUnless the
5005a9db8eSjtc.Fl n
5161f28255Scgdoption is present, a newline is output following the arguments.
5261f28255ScgdThe
5305a9db8eSjtc.Fl e
5461f28255Scgdoption causes
552b0a187fSchristos.Nm
5661f28255Scgdto treat the escape sequences specially, as described in the following
5705a9db8eSjtcparagraph.
5805a9db8eSjtcThe
5905a9db8eSjtc.Fl e
6061f28255Scgdoption is the default, and is provided solely for compatibility with
6161f28255Scgdother systems.
6261f28255ScgdOnly one of the options
6305a9db8eSjtc.Fl n
6461f28255Scgdand
6505a9db8eSjtc.Fl e
6661f28255Scgdmay be given.
6705a9db8eSjtc.Pp
6861f28255ScgdIf any of the following sequences of characters is encountered during
6961f28255Scgdoutput, the sequence is not output.  Instead, the specified action is
7061f28255Scgdperformed:
7105a9db8eSjtc.Bl -tag -width indent
7205a9db8eSjtc.It Li \eb
7361f28255ScgdA backspace character is output.
7405a9db8eSjtc.It Li \ec
7561f28255ScgdSubsequent output is suppressed.  This is normally used at the end of the
7661f28255Scgdlast argument to suppress the trailing newline that
772b0a187fSchristos.Nm
7861f28255Scgdwould otherwise output.
7905a9db8eSjtc.It Li \ef
8061f28255ScgdOutput a form feed.
8105a9db8eSjtc.It Li \en
8261f28255ScgdOutput a newline character.
8305a9db8eSjtc.It Li \er
8461f28255ScgdOutput a carriage return.
8505a9db8eSjtc.It Li \et
8661f28255ScgdOutput a (horizontal) tab character.
8705a9db8eSjtc.It Li \ev
8861f28255ScgdOutput a vertical tab.
8905a9db8eSjtc.It Li \e0 Ns Ar digits
9061f28255ScgdOutput the character whose value is given by zero to three digits.
9161f28255ScgdIf there are zero digits, a nul character is output.
9205a9db8eSjtc.It Li \e\e
9361f28255ScgdOutput a backslash.
9405a9db8eSjtc.El
9505a9db8eSjtc.Sh HINTS
9661f28255ScgdRemember that backslash is special to the shell and needs to be escaped.
9761f28255ScgdTo output a message to standard error, say
9805a9db8eSjtc.Pp
99*01869ca4Swiz.D1  echo message >&2
10005a9db8eSjtc.Sh BUGS
10105a9db8eSjtcThe octal character escape mechanism
10205a9db8eSjtc.Pq Li \e0 Ns Ar digits
10305a9db8eSjtcdiffers from the
10461f28255ScgdC language mechanism.
10505a9db8eSjtc.Pp
10661f28255ScgdThere is no way to force
1072b0a187fSchristos.Nm
10861f28255Scgdto treat its arguments literally, rather than interpreting them as
10961f28255Scgdoptions and escape sequences.
110