Bird
0
0

Given a file log.txt with these lines:

medium📝 Command Output Q4 of 15
Linux CLI - Text Processing
Given a file log.txt with these lines:
info: start
error: failed
warning: low disk
error: timeout

What is the output of grep -E '^error' log.txt?
Aerror: failed error: timeout
Binfo: start warning: low disk
Cerror: failed
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check case sensitivity of grep

    By default, grep is case sensitive. Lines start with lowercase 'error' or uppercase 'Error' matter.
  2. Step 2: Analyze lines starting with 'error'

    Lines start with 'error:' in lowercase, and the pattern is '^error' lowercase, so it matches those lines exactly.
  3. Step 3: Verify output

    Lines 'error: failed' and 'error: timeout' match, so output is those two lines.
  4. Final Answer:

    error: failed error: timeout -> Option A
  5. Quick Check:

    grep is case sensitive by default [OK]
Quick Trick: grep -E is case sensitive unless -i used [OK]
Common Mistakes:
  • Assuming grep ignores case by default
  • Expecting lines starting with 'Error' to match lowercase pattern
  • Confusing output with unrelated lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes