Linux Command - echo

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

1
echo 'Hello Linux'
1
echo "Hello Linux"

Note: single quotes and double quotes are optional

1
echo -n "Hello Linux"
1
echo "\$PATH is $PATH"

Note: can’t use single quotes here. Only String in double quotes interpolates variables.

1
echo -e "name:\tuser1\nid:\t1234"

or

1
echo -e 'name:\tuser1\nid:\t1234'

Reference