Saving output to files
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Catching the output
- Normally a command's output appears on screen. The
>symbol redirects it into a file instead:
echo hello > greeting.txt
- Nothing prints — the text went into
greeting.txt. Read it back withcat greeting.txt.
Replace vs add
>replaces the file's contents (or creates it if new).>>appends — it adds to the end, keeping what was there:
echo line one > notes.txt
echo line two >> notes.txt
- Use
>>when you are building up a file, like a log.
Why this matters
- Saving output lets you keep results, build files from commands, and feed one program's output to another.
- ⚠️ Watch out:
>on an existing file erases it first. Use>>when you mean "add".
Send the output of echo into a file with >. Write hello into greeting.txt, then cat it back.
Click Run to see the output here.
>> adds a line instead of replacing. Write first into log.txt, then append second, then show the file.
Click Run to see the output here.