echo command
Print text and variables.
- Shell & scheduling
- Package shell builtin / coreutils
- 3 options · 6 examples
Syntax
echo [options] [text…]Provided by the shell builtin / coreutils package. Run man echo for the full manual.
Common options
| Option | What it does |
|---|---|
-n | No newline at the end |
-e | Interpret escapes like \n and \t |
-E | Don't interpret escapes (default) |
Examples
Print text
echo "Hello, world"Print a variable
echo "Home is $HOME"No trailing newline
echo -n "Enter name: "Escapes
echo -e "Line 1\nLine 2"Write to a file
echo "export EDITOR=vim" >> ~/.bashrcPrint the last exit code
echo $?
No example matches. Check the options table or search the guides.
Tips
- For exact formatting,
printfis more portable thanecho -e.
echo guides
- echo Command in Linux with Practical Examples Linux Commands · Updated Apr 2025
