echo - Print given arguments.
Syntax
1
| echo [OPTIONS] [STRING]...
|
Common Options
| Option |
Description |
| -n |
do not output the trailing newline |
| -e |
enable interpretation of backslash escapes |
If -e is in effect, the following sequences are recognized:
| String Sequence |
Interpretation |
| \\ |
backslash |
| \a |
alert (BEL) |
| \b |
backspace |
| \c |
produce no further output |
| \e |
escape |
| \f |
form feed |
| \n |
new line |
| \r |
carriage return |
| \t |
horizontal tab |
| \v |
vertical tab |
| \0NNN |
byte with octal value NNN (1 to 3 digits) |
| \xHH |
byte with hexadecimal value HH (1 to 2 digits) |
Examples
Print some text
Note: single quotes and double quotes are optional
Print some text without newline
Print PATH variable
Note: can’t use single quotes here. Only String in double quotes interpolates variables.
Print text with Tabs
1
| echo -e "name:\tuser1\nid:\t1234"
|
or
1
| echo -e 'name:\tuser1\nid:\t1234'
|
Reference