echo
Text processing
Usage
echo [text]Prints its arguments and a newline; -e and backslash handling differ between shells and builds, so printf is the portable choice.
Common flags
| Flag | Meaning |
|---|---|
| -n | Leave off the trailing newline |
| -e | Read backslash escapes such as \n. Not in every shell |
| -E | Do not read escapes, which is the usual default |
Examples
echo -n doneLeaves the cursor on the same line.
echo "$PATH"Prints a variable; the quotes keep spaces intact.
echo *The shell expands this to the file names, not echo.
These were built to be piped together. Three joined commands are usually shorter than one that does everything.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does echo do?
Prints its arguments and a newline; -e and backslash handling differ between shells and builds, so printf is the portable choice.
Q. How do I type it?
echo [text] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
3 are listed here; the full set is in man echo. This command sits under Text processing.
Related commands
man page: man echo