echo prints whatever you hand it. Learn how to check what is inside an environment variable, when to use single or double quotes, and how `>` writes the text to a file, by running the commands in a real terminal in your browser.
Updated: 2026-09-06
echo [options] string...
It prints the strings you pass, followed by a single newline.
$ echo hello world
hello world
Arguments are split on spaces and printed back joined by one space each. That is why extra spaces collapse.
$ echo hello world
hello world
Quote the text to keep it exactly as written.
$ echo "hello world"
hello world
With $, the shell replaces the name with its value before echo ever sees it.
$ echo $HOME
/home/user
$ echo $PATH
/usr/bin:/bin:/usr/local/bin
This is the everyday use. It lets you confirm that a value you thought you set is really there, before you run the thing that depends on it.
Inside double quotes a variable turns into its value. Inside single quotes it does not.
$ echo "deployed by $USER"
deployed by user
$ echo 'deployed by $USER'
deployed by $USER
Use single quotes when you want to show the $ text itself.
> sends the text to a file instead of the screen.
$ echo build ok > result.txt
$ cat result.txt
build ok
>> adds to the end.
$ echo second line >> result.txt
$ cat result.txt
build ok
second line
> overwrites.
Point it at the same file again and whatever was there is gone.
$ echo overwritten > result.txt
$ cat result.txt
overwritten
-e makes escapes such as \t and \n mean tab and newline.
$ echo -e "name\tstatus"
name status
-n leaves off the final newline.
$ echo -n done
done
echo is what you type to check something and to add a single line.
| Situation | What to type |
|---|---|
| Check that an environment variable is set | echo $DATABASE_URL |
| See what is on your PATH | echo $PATH |
| Add one line to a config file | echo "node_modules" >> .gitignore |
| Report progress from a script | echo "deploying..." |
| Create a file with one line in it | echo "# project" > README.md |
> overwrites.
Typing > when you meant to add a line to .gitignore or .env throws away the rest of the file.
Adding is always >>.
A misspelled variable is not an error.
$ echo $NOPE
$ echo "[$NOPE]"
[]
A name that does not exist expands to nothing at all. Wrap it in brackets and you can see whether it is empty.
The shell expands *, not echo.
$ echo *.txt
notes.txt result.txt
echo never sees *.txt.
The shell replaces it with the matching file names first, and hands the result over.
That order is exactly why echo *.txt is worth typing before rm *.txt.
Do not echo secrets.
They stay on the screen and in your shell history.
If you only need to know whether a value is set, printing [$TOKEN] to see that it is not empty is enough.
webterm.appthis site
Terminal Fundamentals
Learn commonly used commands
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the coursecat / printf / export