The echo command prints its argument list, separating each argument with a space, and following the last argument with a newline. For example:
$Variables and file specifications are expanded by the shell before being passed to echo. Consider the following command:
echo Hi there!Hi there! $
This prints the specified text string before producing a listing of all the files in the current working directory, across the screen.
echo recognizes a number of escape sequences which it expands internally. An escape command is a backslash-escaped character that signifies some other character. The ones recognized by echo are common throughout the shell syntax, as follows:
$Here, the escape sequence only is quoted. Otherwise, the whole string can be quoted:
echo The available files are \n *The available files are aaaa bbbb cccc dddd eeee
$For example, see the following echo command:
echo $fooa y $
$The \n escape causes echo to emit a newline, and the \t escape causes echo to emit a tab.
echo "Mary had a little lamb \n \t Its fleece was white as snow"Mary had a little lamb \(t1 Its fleece was white as snow
You can redirect the output from echo. For example, the who and w commands list the users on your system and the terminals they are logged in on. To send a message to a terminal being used by someone else, you can use a command like the following, if /dev/tty015 is the name of the terminal you want to print a message on:
$(Note that this is not the best way to send messages between terminals; write(C) and talk(TC) are commands intended for this purpose, and allow two-way conversation.)
echo Hi there! > /dev/tty015