Ir al contenido principal
kitlocal.dev

Chuleta de Text CLI (grep / sed / awk)

Ejecución local

Procesado al 100 % en tu navegador. Las entradas y salidas nunca salen de tu dispositivo.

Comandos de procesamiento de texto en Unix con pipelines reales: búsqueda con GNU grep/ripgrep, edición de flujos con sed, campos y agregaciones con awk, además de cut, sort, uniq y tr.

Cómo funciona

Unix text tools act like stream filters: each tool reads lines from files or stdin, does one small job (search, slice columns, replace, count, sort) and writes lines to stdout so you can snap them together with `|`.

Kit de supervivencia

Los comandos clave que conviene aprender primero.

41 comandos

Atajos de teclado/Enfocar búsquedaJKMover selecciónCCopiar seleccionadoFMarcar seleccionadoEscBorrar búsqueda

Search lines (grep)

grep prints lines matching a pattern. Add -n for line numbers, -i for case-insensitive and -E for extended regex.

Documentación oficial: grep usage
  • Esencial

    Search recursively and print file paths and line numbers.

    grep -rn "<pattern>" <dir>

    Construye el comando

    grep -rn "<pattern>" <dir>

    Los valores se insertan exactamente como los escribes. Ponlos entre comillas si contienen espacios o caracteres especiales.

    Cuándo usarlo

    Find every occurrence of a function, error code or config key across a directory tree.

    Desglose

    -r
    recurse into subdirectories
    -n
    prefix matches with 1-based line numbers
    <pattern>
    search regex or text
    <dir>
    directory to search (use `.` for current)

    Ejemplo

    printf "200 GET /api\n500 POST /pay\n200 GET /api\n404 GET /old\n" | grep -n "GET"

    Resultado

    1:200 GET /api
    3:200 GET /api
    4:404 GET /old

    También funciona

    • rg "<pattern>" (ripgrep, skips .gitignore automatically)

    Véase también

Transform text streams (sed)

sed edits lines on the fly. Test without `-i` first so you preview changes on stdout before modifying files.

Documentación oficial: sed commands

Process columns & aggregate (awk)

awk splits every line into fields ($1, $2, ...) automatically, running `{ action }` whenever `condition` is true.

Documentación oficial: GNU Awk User Guide

Sort, count, cut & translate

Fast single-purpose coreutils for frequency counts, column slicing and character cleanup.

Documentación oficial: Operating on sorted files

Find files & batch commands (find, xargs)

Locate files by name, size or age and pass them safely to downstream commands using NUL delimiters.

Documentación oficial: GNU Findutils Manual

Pruébalo en una herramienta de KitLocal

Glosario
stdin / stdout
Standard input and output streams wired together by pipes (`|`).
ERE (-E)
Extended Regular Expressions: `+`, `?`, `|`, `()` work without extra backslashes.
Field ($1, $NF)
In awk, columns split by whitespace (or `-F`): `$0` is the whole line, `$NF` is the last column.
NUL delimiter (-0)
Separating paths with `\0` instead of newlines so spaces and quotes never break pipelines.

Comprobado el 15 nov 2026 · Comprobado con GNU grep 3.12 / sed 4.9 / gawk 5.3

Fuentes: GNU Coreutils Manual · GNU grep Manual · GNU sed Manual · GNU Awk Manual

Sustituye todo lo que esté entre corchetes angulares por tus propios valores. Los comandos proceden de la documentación oficial y los ejemplos se ejecutaron en la versión indicada.