MIAP Digital Literacy Command Line Guide

Learn about BASH commands!

View on GitHub

The echo Command

Summary

The echo command displays input text to standard output. It’s often used in a shell script to log status, provide feedback to users, and for debugging. By default the output is displayed in the terminal but can be redirected to a file or piped to another process.

Basic command structure

echo [option] [string]

Possible Flags

-n

The -n flag means it will not output the trailing newline.

-e

The -e flag is used to enable the interpretation of backslash escapes. This allows you to add additional flags in your text block to format the text output.

When -e is added, a variety of other sequences can be added on including:

You can also use the echo command with variables

echo-variable

Output

The echo command has different options for output locations as described below:

Output displayed in command line

Output redirected into a file

echo-to-file

These are just the simplest examples of how to use the ‘echo’ command, but it is a widely used and extremely versatile tool.

Go back to the main list of commands