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:
- \t adds a horizontal tab
- \v adds a vertical tab
- \n adds a new line
You can also use the echo command with variables
Output
The echo command has different options for output locations as described below:
Output displayed in command line
- This is the default ouput unless a different location is specified
Output redirected into a file
- Example: You could use the echo command to log the date you started work on a specific project.
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