echo prints its arguments, separated by spaces, followed by a newline. It is both a shell builtin and a standalone program in /bin/echo (usually the builtin wins), which matters when flags differ.
echo hello world # hello world
echo "$HOME" # variable expansion
echo -n no-newline # suppress trailing newline
echo -e 'tab\there' # interpret escapes (bash builtin)
echo "a" > file # redirect to a file
For reliable behaviour across shells, especially with escapes, prefer printf: its formatting is POSIX-standardised, whereas echo's handling of -e and -n varies.
Discussed in:
- Chapter 5: The Shell — Shell Basics