Online Linux Terminal Logo
OnlineLinuxTerminal
Procesamiento de textoCLI Manual

$grep

Busque patrones de cadenas o expresiones regulares dentro de archivos de texto.

Sintaxis del comandoPOSIX Standard
grep [OPTIONS] PATTERN [FILE...]
Comunidad Linux2.4k En línea

Chatea con usuarios de Linux, aprende comandos y descarga guías PDF.

Prueba en vivo en la terminal interactiva

Simulación del lado del cliente sin instalación y con respuesta inmediata.

Abrir en terminal de pantalla completa ↗
bash — terminal

Descripción general y funcionamiento

Grep es la utilidad estándar de Unix para buscar texto línea por línea mediante expresiones regulares en archivos y flujos de datos.

Opciones y banderas comunes

Flag / OptionDescription
-iIgnore case distinctions in both patterns and input data.
-nPrefix each matched output line with its 1-based line number.
-vInvert the match to print lines that do NOT match the pattern.
-r, -RRecursively search all files under each directory.
-cSuppress normal output and print only the count of matching lines.
-EInterpret pattern as an Extended Regular Expression (ERE).

Ejemplos prácticos del mundo real

#1Search for errors in system log files
grep -i -n "error" /var/log/syslog

Searches /var/log/syslog for case-insensitive occurrences of "error" and prints line numbers.

#2Filter process list through a pipe
ps aux | grep nginx

Pipes process snapshot data and isolates lines containing the nginx web server process.

#3Count total failed authentication attempts
grep -c "Failed password" /var/log/auth.log

Outputs the integer count of failed login attempts without listing every individual line.