View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Echo

From LQWiki

Jump to: navigation, search

echo is a shell command which prints data to the screen. (You may recognize it from some programming languages - Perl and PHP both use it)

For example:

$ echo Hello World
Hello World
$

If run in the context of a shell script, then you can allow echo to print the contents of variables by prefixing the variable name with a dollar sign. For example:


$ x=`date`
$ echo $x
Sat Aug 7 12:57:04 UTC 2004
$ 

It is also possible to output ASCII data. The syntax is

echo -e "\0NNN"

where NNN is the ascii number in octal format. To output an A (ascii code 65), use

echo -e "\0101"

To output all ASCII charaters, use

for l in $(seq 0 1 7); do for i in $(seq 0 1 7); do for n in $(seq 0 1 7); do \
echo -en "\0${l}${i}${n}  ";done;  done;done 

See Also


Personal tools