Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 3: Advanced Text Processing & Production Internals (Senior / Lead)

42%
Bash & Shell Scripting (50 Qs)•Part 3: Advanced Text Processing & Production Internals (Senior / Lead)

How do you use `grep` with Extended Regular Expressions (`-E`) and inverse matching?

senior LevelCode Examplebash-shellAdvanced Text Processing

In Simple Words: grep searches text streams for matching patterns:

  • -E (or egrep): Enables extended regular expressions (+, ?, |, ()).
  • -v: Inverts match (returns lines that do NOT match).
  • -i: Case-insensitive.
  • -o: Prints only the matched parts of a line, not the entire line.
  • -c: Counts matching lines.
bash
# Extract all IP addresses from an access log:
grep -E -o '([0-9]{1,3}\.){3}[0-9]{1,3}' access.log | sort | uniq -c | sort -nr