Saving output to files
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Эта страница требует современного браузера (с поддержкой SharedArrayBuffer). Пожалуйста, обновите Chrome, Edge, Firefox или Safari до последней версии.
English
Catching the output
- Normally a command's output appears on screen. The
>symbol redirects it into a file instead:
- Nothing prints — the text went into
greeting.txt. Read it back withcat greeting.txt.
Русский
Перенаправление вывода
- Обычно вывод команды отображается на экране. Символ
>перенаправляет его в файл вместо экрана:
echo hello > greeting.txt
- Ничего не выводится — текст попал внутрь файла
greeting.txt. Прочитайте его обратно с помощьюcat greeting.txt.
English
Replace vs add
>replaces the file's contents (or creates it if new).>>appends — it adds to the end, keeping what was there:
- Use
>>when you are building up a file, like a log.
Русский
Замена против добавления
>заменяет содержимое файла (или создает новый, если его нет).>>добавляет — он дописывает в конец, сохраняя то, что было там ранее:
echo line one > notes.txt
echo line two >> notes.txt
- Используйте
>>, когда накапливаете данные в файле, например, в журнале событий.
English
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".
Русский
Почему это важно
- Сохранение вывода позволяет сохранить результаты, создавать файлы из команд и передавать вывод одной программы другой.
- ⚠️ Осторожно:
>на существующем файле сначала стирает его. Используйте>>, если вы имеете в виду «добавить».
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
Русский
Распространенные ошибки
>перезаписывает файл;>>добавляет в конец.>на файле, который уже существует, сначала удаляет его.
Send the output of echo into a file with >. Write hello into greeting.txt, then cat it back.
>> adds a line instead of replacing. Write first into log.txt, then append second, then show the file.