Online Linux Terminal Logo
OnlineLinuxTerminal
TextverarbeitungCLI Manual

$grep

Suchen Sie nach Zeichenfolgenmustern oder regulären Ausdrücken in Textdateien.

BefehlssyntaxPOSIX Standard
grep [OPTIONS] PATTERN [FILE...]
Linux-Community2.4k Online

Tausche dich mit Linux-Nutzern aus, lerne Befehle und lade PDF-Cheatsheets herunter.

Live im interaktiven Terminal ausprobieren

Client-seitige Simulation ohne Installation mit sofortigem Feedback.

Im Vollbild-Terminal öffnen ↗
bash — terminal

Überblick & Funktionsweise

Grep ist das Standard-Unix-Werkzeug zum Durchsuchen von Textdateien und Logfiles mittels regulärer Ausdrücke.

Wichtige Optionen und Flags

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).

Praktische Anwendungsbeispiele

#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.