What are practical uses of the echo command?

Question

We see here that the echo command can print to the standard output (usually the terminal) whatever we pass to it as an argument:

$ echo Hello!
Hello!
$

How do we practically utilize this command?

Answer

Let’s keep in mind here that the value of the command line functions is not only that we can use them in the terminal, but that we can write programs, called shell scripts, with them.

The echo command plays the same role as the print function in other languages. Along with printing common strings, “Hello!”, we can print the values of environmental variables to the standard output with echo. For example echo $PATH, will print the value of PATH: your search path. In this way, echo is as practical as any other print function.

19 Likes