Merge commit '8c331166625387ef510c183eb42ba2dec1af7a0d' into merges
[unleashed.git] / bin / echo / echo.1
bloba640438670653154fc2f1aa0072b43112daef1f0
1 '\" te
2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved
4 .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
5 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\"  This notice shall appear on any product containing this material.
10 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
11 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
12 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
13 .TH ECHO 1 "Apr 14, 2016"
14 .SH NAME
15 echo \- echo arguments
16 .SH SYNOPSIS
17 .LP
18 .nf
19 \fB/usr/bin/echo\fR [\fIstring\fR]...
20 .fi
22 .SH DESCRIPTION
23 .LP
24 The \fBecho\fR utility writes its arguments, separated by BLANKs and terminated
25 by a NEWLINE, to the standard output. If there are no arguments, only the
26 NEWLINE character is written.
27 .sp
28 .LP
29 \fBecho\fR is useful for producing diagnostics in command files, for sending
30 known data into a pipe, and for displaying the contents of environment
31 variables.
32 .sp
33 .LP
34 The C shell, the Korn shell, and the Bourne shell all have \fBecho\fR built-in
35 commands, which, by default, is invoked if the user calls \fBecho\fR without a
36 full pathname. See \fBshell_builtins\fR(1). \fBsh\fR's \fBecho\fR, \fBksh\fR's
37 \fBecho\fR, \fBksh93\fR's \fBecho\fR, and \fB/usr/bin/echo\fR understand the
38 back-slashed escape characters, except that \fBsh\fR's \fBecho\fR does not
39 understand \fB\ea\fR as the alert character. In addition, \fBksh\fR's and
40 \fBksh93\fR's \fBecho\fR does not have an \fB-n\fR option.
41 \fBcsh\fR's \fBecho\fR, on the other hand, has an
42 \fB-n\fR option, but does not understand the back-slashed escape characters.
43 .SH OPERANDS
44 .LP
45 The following operand is supported:
46 .sp
47 .ne 2
48 .na
49 \fB\fIstring\fR\fR
50 .ad
51 .RS 10n
52 A string to be written to standard output. If any operand is "\fB-n\fR", it is
53 treated as a string, not an option. The following character sequences is
54 recognized within any of the arguments:
55 .sp
56 .ne 2
57 .na
58 \fB\fB\ea\fR\fR
59 .ad
60 .RS 8n
61 Alert character.
62 .RE
64 .sp
65 .ne 2
66 .na
67 \fB\fB\eb\fR\fR
68 .ad
69 .RS 8n
70 Backspace.
71 .RE
73 .sp
74 .ne 2
75 .na
76 \fB\fB\ec\fR\fR
77 .ad
78 .RS 8n
79 Print line without new-line. All characters following the \fB\ec\fR in the
80 argument are ignored.
81 .RE
83 .sp
84 .ne 2
85 .na
86 \fB\fB\ef\fR\fR
87 .ad
88 .RS 8n
89 Form-feed.
90 .RE
92 .sp
93 .ne 2
94 .na
95 \fB\fB\en\fR\fR
96 .ad
97 .RS 8n
98 New-line.
99 .RE
102 .ne 2
104 \fB\fB\er\fR\fR
106 .RS 8n
107 Carriage return.
111 .ne 2
113 \fB\fB\et\fR\fR
115 .RS 8n
116 Tab.
120 .ne 2
122 \fB\fB\ev\fR\fR
124 .RS 8n
125 Vertical tab.
129 .ne 2
131 \fB\fB\e\e\fR\fR
133 .RS 8n
134 Backslash.
138 .ne 2
140 \fB\fB\e0\fR\fIn\fR\fR
142 .RS 8n
143 Where \fIn\fR is the 8-bit character whose \fBASCII\fR code is the 1-, 2- or
144 3-digit octal number representing that character.
149 .SH USAGE
151 Portable applications should not use \fB-n\fR (as the first argument) or escape
152 sequences.
154 New applications are encouraged to use \fBprintf\fR instead of \fBecho\fR.
155 .SH EXAMPLES
157 \fBExample 1 \fRFinding how far below root your current directory is located
160 You can use \fBecho\fR to determine how many subdirectories below the root
161 directory (\fB/\fR) is your current directory, as follows:
163 .RS +4
165 .ie t \(bu
166 .el o
167 Echo your current-working-directory's full pathname.
169 .RS +4
171 .ie t \(bu
172 .el o
173 Pipe the output through \fBtr\fR to translate the path's embedded
174 slash-characters into space-characters.
176 .RS +4
178 .ie t \(bu
179 .el o
180 Pipe that output through \fBwc\fR \fB-w\fR for a count of the names in your
181 path.
183 .in +2
185 example% \fB/usr/bin/echo $PWD | tr '/' ' ' | wc -w\fR
187 .in -2
193 See \fBtr\fR(1) and \fBwc\fR(1) for their functionality.
197 Below are the different flavors for echoing a string without a NEWLINE:
199 \fBExample 2 \fR/usr/bin/echo
201 .in +2
203 example% \fB/usr/bin/echo "$USER's current directory is $PWD\ec"\fR
205 .in -2
209 \fBExample 3 \fRsh/ksh shells
211 .in +2
213 example$ \fBecho "$USER's current directory is $PWD\ec"\fR
215 .in -2
219 \fBExample 4 \fRcsh shell
221 .in +2
223 example% \fBecho -n "$USER's current directory is $PWD"\fR
225 .in -2
228 .SH ENVIRONMENT VARIABLES
230 See \fBenviron\fR(5) for descriptions of the following environment variables
231 that affect the execution of \fBecho\fR: \fBLANG\fR, \fBLC_ALL\fR,
232 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
234 .SH EXIT STATUS
236 The following error values are returned:
238 .ne 2
240 \fB\fB0\fR\fR
242 .RS 6n
243 Successful completion.
247 .ne 2
249 \fB\fB>0\fR\fR
251 .RS 6n
252 An error occurred.
255 .SH ATTRIBUTES
257 See \fBattributes\fR(5) for descriptions of the following attributes:
262 box;
263 c | c
264 l | l .
265 ATTRIBUTE TYPE  ATTRIBUTE VALUE
267 CSI     Enabled
269 Interface Stability     Committed
271 Standard        See \fBstandards\fR(5).
274 .SH SEE ALSO
276 \fBksh93\fR(1), \fBprintf\fR(1), \fBshell_builtins\fR(1), \fBtr\fR(1),
277 \fBwc\fR(1), \fBecho\fR(1B), \fBascii\fR(5), \fBattributes\fR(5),
278 \fBenviron\fR(5), \fBstandards\fR(5)
279 .SH NOTES
281 When representing an 8-bit character by using the escape convention
282 \fB\e0\fR\fIn\fR, the \fIn\fR must \fBalways\fR be preceded by the digit zero
283 (\fB0\fR).
286 For example, typing: \fBecho 'WARNING:\e\|07'\fR prints the phrase
287 \fBWARNING:\fR and sounds the "bell" on your terminal. The use of single (or
288 double) quotes (or two backslashes) is required to protect the "\|\e" that
289 precedes the "07".
292 Following the \fB\e0\fR, up to three digits are used in constructing the octal
293 output character. If, following the \fB\e0\fR\fIn\fR, you want to echo
294 additional digits that are not part of the octal representation, you must use
295 the full 3-digit \fIn\fR. For example, if you want to echo "ESC 7" you must use
296 the three digits "033" rather than just the two digits "33" after the
297 \fB\e\|0\fR\&.
299 .in +2
301 2 digits         Incorrect:      echo "\e0337" | od -xc
302                  produces:       df0a                     (hex)
303                                  337                      (ascii)
304 3 digits         Correct:        echo "\e00337" | od -xc
305                  produces:       lb37 0a00                (hex)
306                                  033 7                    (ascii)
308 .in -2
313 For the octal equivalents of each character, see \fBascii\fR(5).