Online Linux Terminal Logo
OnlineLinuxTerminal
Text ProcessingCLI Reference

$echo

Print text strings or write data to files using shell redirection.

Syntax DefinitionPOSIX standard
echo [OPTIONS] [STRING...]
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `echo` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

Overview & How echo Works

`echo` displays strings of text to standard output. When paired with `>` (overwrite) or `>>` (append) redirection operators, `echo` is the most common way to create config files, append environment variables, or print script debug statuses.

Common Flags & Command Options

Flag / OptionDescription
-eEnable interpretation of backslash escapes (e.g., \n for newline, \t for tab).
-nDo not output the trailing newline character.

Practical Real-World Examples

Example #1Write text to a new file
echo "API_PORT=8080" > /home/user/.env && cat /home/user/.env

Creates or overwrites .env with API_PORT=8080.

Sample Output:
API_PORT=8080

Frequently Asked Questions

What is the difference between > and >> in echo?

`>` completely overwrites the target file, while `>>` appends new text to the end of the file preserving existing content.