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