Getting older, not necessarily wiser!
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).
The syntax of the echo command is:
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.
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.
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.