Saving output to files · Enregistrer la sortie vers des fichiers
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Cette page nécessite un navigateur récent (avec support SharedArrayBuffer). Veuillez mettre à jour Chrome, Edge, Firefox ou Safari vers la dernière version.
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.
Français
Capturer la sortie
- Normalement, la sortie d'une commande s'affiche à l'écran. Le symbole
>redirige cette sortie vers un fichier :
echo hello > greeting.txt
- Rien ne s'affiche — le texte est allé dans
greeting.txt. Relisez-le aveccat 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.
Français
Remplacer vs Ajouter
>remplace le contenu du fichier (ou le crée s'il est nouveau).>>append — il ajoute à la fin, en gardant ce qui était là :
echo line one > notes.txt
echo line two >> notes.txt
- Utilisez
>>lorsque vous construisez un fichier, comme un journal.
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".
Français
Pourquoi c'est important
- Enregistrer la sortie permet de conserver les résultats, de construire des fichiers à partir de commandes et de passer la sortie d'un programme à un autre.
- ⚠️ Attention :
>sur un fichier existant l'efface d'abord. Utilisez>>si vous voulez dire "ajouter".
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
Français
Erreurs courantes
>écrase un fichier ;>>ajoute à la fin.>sur un fichier qui existe déjà l'efface d'abord.
Send the output of echo into a file with >. Write hello into · dans greeting.txt, then cat it back. · Envoyez la sortie de echo dans un fichier avec >. Écrivez hello dans greeting.txt, puis cat la à nouveau.
>> adds a line instead of replacing. Write first into · dans log.txt, then append second, then show the file. · >> ajoute une ligne au lieu de remplacer. Écrivez first dans log.txt, puis ajoutez second, puis affichez le fichier.