9 - Linux Echo command

Echo command

Echo command is used to display text or the values of a variable.

Syntax

    bash:>
    echo [option] [string,variables]
  

Options

  • [-n] -Do not output the trailing new line.
  • [-e] -Enable interpretation of the following backslash escaped characters in the strings.
  • [a] -alert (bell).
  • [b] -backspace.
  • [c] -suppress trailing new line.
  • [n] -new line.
  • [r] -carriage return.
  • [t] -horizontal tab.
  • [\] -backslash.
  • Note - to use this options we need to use the -e after the echo command and before the option.

    Examples of echo command use

    Simple echo, output's a string:

    Show a Environment Variable using echo:

    It will show the values stored into HOME variable, in our case the HOME variable stores the path to the home of current user.

    It will print a new line for us, everything that is after the n will be outputed on another line.

    It will add a horizontal tab space to our line in the place where the t is placed.