Basic Linux Tutorial
Computer Tutorial

The echo Command

The echo Command

The echo command is used to display text on your screen. This command uses escape characters that can be used to format the displayed text to enhance its readability.

There are several special escape characters that the echo command interprets that provide line control. Each escape character must be preceded by a backslash (\) and enclosed in quotes ("). These escape characters are interpreted by echo, not by the shell.

The read command will specify a list of variable names, whose values will be assigned to the words (delimited by white space) that the user supplies at the prompt. If there are more variables specified by the read command than there are words of input, the leftover variables are assigned to NULL. If the user provides more words than there are variables, all leftover data is assigned to the last variable in the list.

Escape Characters Used with the echo Command

Character Effect
\a Alert character (beep)
\b Backspace
\c Suppress new line at the end of displayed text
\f Form feed
\n Insert a new line character
\r Carriage return
\t Insert a tab character
\\ Backslash
\nnn Character having ASCII value nnn in the octal format. The first n is 0