blob: ebc9ff5f843276c92fc57a3f5b817e53cd5699e8 [file] [log] [blame]
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01001.. index::
2 single: echo (command)
3
Heinrich Schuchardt00a79612021-01-21 17:33:44 +01004echo command
5============
6
7Synopsis
8--------
9
10::
11
12 echo [-n] [args ...]
13
14Description
15-----------
16
17The echo command prints its arguments to the console separated by spaces.
18
19-n
20 Do not print a line feed after the last argument.
21
22args
23 Arguments to be printed. The arguments are evaluated before being passed to
24 the command.
25
26Examples
27--------
28
29Strings are parsed before the arguments are passed to the echo command:
30
31::
32
33 => echo "a" 'b' c
34 a b c
35 =>
36
37Observe how variables included in strings are handled:
38
39::
40
41 => setenv var X; echo "a)" ${var} 'b)' '${var}' c) ${var}
42 a) X b) ${var} c) X
43 =>
44
45
46-n suppresses the line feed:
47
48::
49
50 => echo -n 1 2 3; echo a b c
51 1 2 3a b c
52 => echo -n 1 2 3
53 1 2 3=>
54
55A more complex example:
56
57::
58
59 => for i in a b c; do for j in 1 2 3; do echo -n "${i}${j}, "; done; echo; done;
60 a1, a2, a3,
61 b1, b2, b3,
62 c1, c2, c3,
63 =>
64
65Return value
66------------
67
68The return value $? is always set to 0 (true).