Saving output to files · Guardar la salida en archivos
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · Esta página necesita un navegador reciente (con soporte para SharedArrayBuffer). Por favor, actualiza Chrome, Edge, Firefox o Safari a la última versión.
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.
Español
Capturar la salida
- Por lo general, la salida de un comando aparece en la pantalla. El símbolo
>redirecciona esa salida hacia un archivo en su lugar:
echo hello > greeting.txt
- No se imprime nada — el texto fue guardado dentro de
greeting.txt. Puedes leerlo nuevamente concat 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.
Español
Reemplazar vs. Añadir
>reemplaza el contenido del archivo (o lo crea si no existe).>>apende — añade al final, conservando lo que ya había:
echo line one > notes.txt
echo line two >> notes.txt
- Usa
>>cuando estés construyendo un archivo gradualmente, como por ejemplo un registro (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".
Español
Por qué es importante
- Guardar la salida te permite conservar resultados, construir archivos a partir de comandos y conectar la salida de un programa con la entrada de otro.
- ⚠️ Ten cuidado: usar
>sobre un archivo existente borra su contenido primero. Usa>>cuando quieras decir "añadir".
English
Common mistakes
>overwrites a file;>>adds to the end.>on a file that already exists erases it first.
Español
Errores comunes
>sobrescribe un archivo;>>añade al final.- Usar
>sobre un archivo que ya existe borra su contenido previo.
Send the output of echo into a file with >. Write hello into · dentro de greeting.txt, then cat it back. · Envía la salida de echo a un archivo con >. Escribe hello en greeting.txt, luego muéstralo con cat.
>> adds a line instead of replacing. Write first into · dentro de log.txt, then append second, then show the file. · >> agrega una línea en lugar de reemplazar. Escribe first en log.txt, luego agrega second, y muestra el archivo.