$
학습 Linux 안내서
ko
XP:0
퀘스트 29Regex Ninja
+260 XP

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

이 퀘스트를 위한 인터랙티브 터미널 시작→설치 불필요 • 브라우저에서 바로 실행

개념 및 개요

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.

명령어 구문 참조

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

검증 목표

  • ○
    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

퀘스트를 완료할 준비가 되셨나요? 29?