Skip to content

The echo command

Print a line of text. Prints its arguments separated by spaces, then a new line. Variables such as $HOME are filled in by the shell first. With > or >> you can send the text into a file.

Usage

echo [-n] [-e] [TEXT]...

Options

-nno new line at the end
-eunderstand \n (new line) and \t (tab) in the text

Examples

  • echo HelloPrints Hello
  • echo "My home is $HOME"Fills in the variable
  • echo milk >> shopping.txtAdds a line to the end of a file

Learn it step by step

learner@sandbox: ~bash (practice)
Note: Try echo here: your home directory has sample files. Press Try beside an example, or type your own.

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.