Bird
0
0

Which of the following is the correct syntax to redirect only error messages to a file named error.txt?

easy📝 Syntax Q3 of 15
Linux CLI - Pipes and Redirection
Which of the following is the correct syntax to redirect only error messages to a file named error.txt?
Acommand >2 error.txt
Bcommand 2> error.txt
Ccommand 2>> error.txt
Dcommand >>2 error.txt
Step-by-Step Solution
Solution:
  1. Step 1: Recognize correct redirection syntax

    The correct syntax to redirect stderr is file descriptor 2 followed by > and the filename.
  2. Step 2: Validate options

    command 2> error.txt uses correct syntax: command 2> error.txt. Options B and D have wrong order, C appends instead of overwrite.
  3. Final Answer:

    command 2> error.txt -> Option B
  4. Quick Check:

    Correct stderr syntax = A [OK]
Quick Trick: Use '2>' before filename to redirect errors [OK]
Common Mistakes:
  • Placing '2' after '>' instead of before
  • Using '>>' when overwrite is needed
  • Mixing output and error redirection syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes