Bird
0
0

Which of the following is the correct syntax to use stdin redirection with the command grep to search for 'error' in a file named log.txt?

easy📝 Syntax Q3 of 15
Linux CLI - Pipes and Redirection
Which of the following is the correct syntax to use stdin redirection with the command grep to search for 'error' in a file named log.txt?
Agrep error < log.txt
Bgrep < error log.txt
Cgrep error > log.txt
Dgrep error log.txt <
Step-by-Step Solution
Solution:
  1. Step 1: Understand grep command syntax

    grep searches for a pattern in input. Using < redirects file content as input.
  2. Step 2: Check correct placement of redirection

    grep error < log.txt correctly places < after the pattern and before the filename to redirect input.
  3. Final Answer:

    grep error < log.txt -> Option A
  4. Quick Check:

    Correct stdin redirection syntax = grep error < log.txt [OK]
Quick Trick: Place < before filename to redirect input to commands [OK]
Common Mistakes:
  • Putting < before the pattern
  • Using > which redirects output
  • Leaving < at the end without filename

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes