Display message on screen, writes each given STRING to standard output, with a space between each and a newline after the last one.
Syntax
echo [options]... [string]...
Options
-n
Do not output the trailing newline.
-E
Disable the interpretation of the following backslash-escaped characters
-e
Enable interpretation of the following backslash-escaped
characters in each STRING:
\a alert (bell)
\b backspace
\c suppress trailing newline
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\NNN
the character whose ASCII code is NNN (octal); if NNN is not
a valid octal number, it is printed literally.
\xnnn
the character whose ASCII code is the hexadecimal value
nnn (one to three digits)
echo is a BASH built-in command
Examples
Echo can also display in color by using Escape sequences for foreground (30..37) and background (40..47) colours.
$ COL_BLUE="\x1b[34;01m"
$ COL_RESET="\x1b[39;49;00m"
$ echo -e $COL_BLUE"Important Message: "$COL_RESET"This is a message"
Here is a shell script to display all the color combinations:
#!/bin/bash
#
echo ---Bg---40---41---42---43---44---45---46---47
for i in {30..37} # foreground
do
echo -n -e fg$i-
for j in {40..47} # background
do
echo -n -e '\E['$i';'$j'm SS64'
tput sgr0 # Reset text attributes to normal without clear
done
echo # newline
done
echo -- Clear BG --
for n in {30..37} # foreground
do
echo -e fg$n '\E['$n';'01'm SS64'
tput sgr0 # Reset text attributes to normal without clear
done
"The only thing that helps me pass the time away; is knowing I'll be back at Echo Beach some day" - Martha and the Muffins
Related:
head - Output the first part of file(s)
less - Display output one screen at a time
more - Display output one screen at a time
pg - Display one page at a time
tee - Redirect output to multiple files
Equivalent Windows command: ECHO - Display message on screen