Glossary

echo

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.

Related terms: printf, Shell, stdout

Discussed in:

This site is currently in Beta. Contact: Chris Paton

Textbook of AI · Textbook of Usability · Textbook of Digital Health

Auckland Maths and Science Tutoring

AI tools used: Claude (research, coding, text), ChatGPT (diagrams, images), Grammarly (editing).