Saving output to files · Salvando saída em arquivos
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página precisa de um navegador recente (com suporte a SharedArrayBuffer). Por favor, atualize Chrome, Edge, Firefox ou Safari para a versão mais recente.
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.
Português
Capturando a saída
- Normalmente a saída de um comando aparece na tela. O símbolo
>redireciona isso para um arquivo em vez disso:
echo hello > greeting.txt
- Nada é impresso — o texto foi para dentro de
greeting.txt. Leia-o novamente comcat 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.
Português
Substituir vs Adicionar
>substitui o conteúdo do arquivo (ou o cria se for novo).>>apende — ele adiciona no final, mantendo o que estava lá:
echo line one > notes.txt
echo line two >> notes.txt
- Use
>>quando estiver acumulando um arquivo, como um log.
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".
Português
Por que isso importa
- Salvar a saída permite manter resultados, construir arquivos a partir de comandos e alimentar a saída de um programa para outro.
- ⚠️ Atenção:
>em um arquivo existente apaga-o primeiro. Use>>quando quiser dizer "adicionar".
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
Português
Erros comuns
>sobrescreve um arquivo;>>adiciona ao final.>em um arquivo que já existe apaga-o primeiro.
Send the output of echo into a file with >. Write hello into · em greeting.txt, then cat it back. · Envie a saída de echo para um arquivo com >. Escreva hello em greeting.txt, depois cat de volta.
>> adds a line instead of replacing. Write first into · em log.txt, then append second, then show the file. · >> adiciona uma linha em vez de substituir. Escreva first em log.txt, depois anexe second, depois mostre o arquivo.