All about echo Command

The echo command ‘echoes’ its argument to the standard output.

This means that in its simplest form it prints something out on screen.

For example:

# echo Wikiconsole.com             - you type
Wikiconsole.com                    - response from the shell%

Syntax:

echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION
Example:
# echo Welcome to Wikiconsole.com


Description

Echo the STRING(s) to standard output.

Options

-n     do not output the trailing newline

-e     enable interpretation of backslash escapes

-E     disable interpretation of backslash escapes (default)

Escape Sequence

If -e is in effect, the following sequences are recognized:

       \\     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)

Fonts Properties:

echo command can change font style, background color of fonts and font colors. Escape sequence \033 can be used to alter font properties. -e option has to be used in order to the escape sequence be in effect. Various escape codes are as follows:

[0m: Normal

[1m: Bold fonts

[2m: Font color changes to Purple

[4m: Underlined fonts

[7m: Invert foreground and background colors

[8m: Invisible fonts

[9m: Cross lined fonts

[30m: Font color changes to Grey

[31m: Font color changes to Red

[32m: Font color changes to Green

[33m: Font color changes to Brown

[34m: Font color changes to Blue

[35m: Font color changes to Viole

[36m: Font color changes to Sky Blue

[37m: Font color changes to Light Grey

[38m: Font color changes to Black

[40m: Background color changes to Black

[41m: Background color changes to Red

[42m: Background color changes to Green

[43m: Background color changes to Brown

[44m: Background color changes to Blue

[45m: Background color changes to Violet

[46m: Background color changes to Sky Blue

[47m: Background color changes to Light Grey

Example: 1

echo -e “\033[31mWelcome to Wikiconsole.com\033[0m”

The above command would print “Welcome to Wikiconsole.com” in red color.

 

Example: 2

echo -e “\033[1m\033[42mWelcome to Wikiconsole.com\033[0m”

The above command would print “Welcome to Wikiconsole.com” in bold style and red background color.