Linux Command: echo

Published on December 12, 2021 at 7:03 am by LEW


The echo command simply sends its arguments to stdout. This command, form my experience, has two common use cases for most average users. The first is sending output to the screen from a script. The second is displaying various environmental variables.

Note that this command appears across a wide range of operating systems, sometimes with minor variations in usage. Because of this it is generally consider non portable when used in scripts (the printf command being much better behaved).

Syntax and Function

The syntax of the echo command is:

echo [options][string]

Note that typing echo by itself returns nothing, not even an error. This is why all arguments and options are optional.


I will not be getting into using echo in a script, but instead focus will be on usage from the command line. Our first example simply prints back the word we type as the string tot he screen.

echo “The quick brown fox jumped over the lazy dog”

This second example is a little bit more useful from the command line. We will echo the content of a shell variable to the screen.

echo $TERM

The $TERM variable tells us the type of terminal is being used. In my case the return is xterm. If you wanted to know which shell interpreter is being used, you would echo the $SHELL variable. In my case it is /bin/bash.

echo $SHELL


The echo command generally has only a few options (depending on implementation).


The echo command is a quick way of viewing your terminal environmental variables, or any other variables that haveĀ  set. It is also very useful for outputtingĀ  data from a script to the terminal screen.

[…] the echo command, printf accepts a formatting string, and a more standardized interface. How echo works can […]

Add New Comment

Your email address will not be published. Required fields are marked *