$echo
Print text strings or write data to files using shell redirection.
echo [OPTIONS] [STRING...]Try `echo` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
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 / Option | Description |
|---|---|
| -e | Enable interpretation of backslash escapes (e.g., \n for newline, \t for tab). |
| -n | Do not output the trailing newline character. |
Practical Real-World Examples
echo "API_PORT=8080" > /home/user/.env && cat /home/user/.envCreates or overwrites .env with 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.
Related Linux Commands
Search for matching string patterns or regular expressions inside text files.
Concatenate and print file contents directly to the terminal standard output.
Create empty files or update file access and modification timestamps.
Output the first part (top lines) of text files.
Output the last part (bottom lines) of files or stream real-time logs.
Print newline, word, and byte counts for files.