Bird
0
0

Identify the error in this command intended to redirect errors to errors.log:

medium📝 Troubleshoot Q14 of 15
Bash Scripting - Error Handling
Identify the error in this command intended to redirect errors to errors.log:

command 2>2 errors.log
AShould use &> instead of 2>
BMissing space between command and 2>
CExtra '2' causes errors to be redirected to file named '2' instead of 'errors.log'
DNo error, command is correct
Step-by-Step Solution
Solution:
  1. Step 1: Examine the redirection syntax

    The correct syntax to redirect errors is 2> filename. Here, 2>2 errors.log redirects stderr to file 2, treating errors.log as a command argument.
  2. Step 2: Identify the cause of error

    The extra '2' makes the filename 2 instead of errors.log.
  3. Final Answer:

    Extra '2' causes errors to be redirected to file named '2' instead of 'errors.log' -> Option C
  4. Quick Check:

    2> must be followed by correct filename [OK]
Quick Trick: Check redirection target filename after 2> [OK]
Common Mistakes:
MISTAKES
  • Adding extra numbers or symbols in filename position
  • Confusing &> with 2>
  • Missing spaces causing parsing errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes