$
Apprendre Manuel Linux
fr
XP :0
Quête 29Regex Ninja
+260 XP

Advanced grep Flags (-i, -v, -r, -E)

Lancer le terminal interactif pour cette quête→Aucune installation requise • S'exécute dans le navigateur

Concept et aperçu

While basic grep searches for exact strings, production log analysis requires powerful matching flags:

- -i: Case-insensitive search (matches error, Error, or ERROR).
- -v: Invert match (prints lines that do not match the given pattern, perfect for stripping noise).
- -r (or -R): Recursive directory search across all subdirectories and files.
- -E: Extended regular expressions (supports | alternation for multiple patterns, +, and parentheses without escape backslashes).

Practice advanced log triage on files inside logs/:
1. Run grep -i "error" logs/app.log to match errors regardless of uppercase/lowercase.
2. Run grep -v "INFO" logs/app.log to filter out routine info lines.
3. Run grep -r "SSH" logs/ to recursively locate SSH activity across all log files in logs/.
4. Run grep -E "(WARNING|ERROR)" logs/app.log to match lines containing either WARNING or ERROR using extended regex.

Référence de syntaxe des commandes

Command / SyntaxDescription
grep -i "error" logs/app.logCase-insensitive pattern search
grep -v "INFO" logs/app.logInvert search (exclude lines matching pattern)
grep -r "SSH" logs/Recursively search all files in directory
grep -E "(WARNING|ERROR)" logs/app.logSearch with extended regex alternation

Objectifs de vérification

  • ○
    Run case-insensitive grep (-i) on logs/app.log
  • ○
    Run inverted grep (-v) to exclude INFO
  • ○
    Run recursive grep (-r) across logs/
  • ○
    Run extended regex grep (-E) with alternation

Prêt à terminer la Quête 29?