Linux and Unix echo command tutorial with examples

The “echo” command in Unix is often used in the shell script for displaying/printing messages on the terminal.
There are two uses of the “echo” command.

  • “echo” is used for display/print messages on the terminal.
  • “echo” is also used to evaluate shell variables.

1. echo to print messages on the terminal.

Echo with options

-n: This option prevents the trailing newline character from being printed. It is useful when you want to display text without a newline at the end.

The [OPTIONS] are optional parameters that modify the behavior of the echo command, and the [STRING] is the text or variables to be displayed.

-e: This option enables the interpretation of escape sequences in the given string.

Echo Command options

OptionDescription
-nPrevents the trailing newline character from being printed
-eEnables interpretation of escape sequences in the string
-EDisables interpretation of escape sequences
-cSuppresses the trailing newline character (combined with -n)

2. echo to evaluate shell variables

What does the echo command do

It is used to display message on terminal

Read More

Unix Linux date command tutorial with examples