Bird
0
0

You want to find all lines containing either 'error' or 'fail' in system.log. Which command achieves this?

hard📝 Application Q8 of 15
Linux CLI - Text Processing
You want to find all lines containing either 'error' or 'fail' in system.log. Which command achieves this?
Agrep 'error fail' system.log
Bgrep -i 'error fail' system.log
Cgrep -E 'error|fail' system.log
Dgrep -v 'error|fail' system.log
Step-by-Step Solution
Solution:
  1. Step 1: Understand pattern matching for multiple words

    Using -E enables extended regex, allowing alternation with | to match 'error' or 'fail'.
  2. Step 2: Check other options

    grep 'error fail' system.log and C search for the exact phrase 'error fail', and D inverts the match.
  3. Final Answer:

    grep -E 'error|fail' system.log -> Option C
  4. Quick Check:

    Use -E with | to match multiple patterns [OK]
Quick Trick: Use grep -E 'pattern1|pattern2' for OR matches [OK]
Common Mistakes:
  • Searching for phrase instead of alternatives
  • Using -v to invert unintentionally
  • Not using -E for regex alternation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes