Bird
0
0

You want to count how many lines in data.txt contain the word 'error' ignoring case, using stdin redirection. Which command achieves this?

hard📝 Application Q15 of 15
Linux CLI - Pipes and Redirection
You want to count how many lines in data.txt contain the word 'error' ignoring case, using stdin redirection. Which command achieves this?
Awc -l < grep -i 'error' data.txt
Bgrep -i 'error' < data.txt | wc -l
Cgrep 'error' > data.txt | wc -l
Dgrep -i 'error' > data.txt | wc -l
Step-by-Step Solution
Solution:
  1. Step 1: Use grep with case-insensitive option and stdin redirection

    grep -i 'error' < data.txt reads data.txt ignoring case.
  2. Step 2: Pipe output to wc -l to count matching lines

    Adding | wc -l counts the number of lines output by grep.
  3. Final Answer:

    grep -i 'error' < data.txt | wc -l -> Option B
  4. Quick Check:

    Use grep -i with < and pipe to wc -l [OK]
Quick Trick: Pipe grep output to wc -l for counting lines [OK]
Common Mistakes:
  • Using > instead of < for input
  • Placing wc -l before grep
  • Redirecting output to input file mistakenly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes