io

echo

Writes arguments to stdout separated by spaces and terminated with a newline. Behavior across systems is inconsistent (especially escape processing) — prefer printf for anything with formatting or portability requirements.

echo [-neE] [ARG ...]

Common flags / operators

Flag / Operator Purpose
-n Suppress the trailing newline
-e Enable interpretation of backslash escapes (\n, \t)
-E Explicitly disable escape interpretation (default)
-- NOT supported — echo treats -- as literal text

Examples

echo "hello $USER"

Prints hello followed by the username plus a newline.

echo -n "progress..."

No trailing newline — cursor stays on the same line.

echo -e "a\tb\nc"

Tab between a and b, newline between b and c.

echo "$var" > file.txt

Redirect echo output to a file.

Gotcha

'echo -n' works in bash but sh (dash) prints '-n' literally — use printf for portable no-newline output. Arguments beginning with dashes may be misparsed as flags; printf '%s\n' "$x" is safer.

Related

← All Bash builtins · Linux commands