Bird
0
0

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

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

command 2> & error.log
AThe redirection operator '2>' is incorrect for errors
BThe ampersand '&' should be replaced with '1'
CThere is a space between '2>' and '&' causing syntax error
DThe filename 'error.log' must be quoted
Step-by-Step Solution
Solution:
  1. Step 1: Analyze redirection syntax

    Redirection operators like '2>&1' must not have spaces between parts.
  2. Step 2: Identify the syntax error

    Space between '2>' and '&' breaks syntax, causing error.
  3. Final Answer:

    There is a space between '2>' and '&' causing syntax error -> Option C
  4. Quick Check:

    No spaces allowed in redirection like 2>&1 [OK]
Quick Trick: No spaces allowed in redirection operators like 2>&1 [OK]
Common Mistakes:
MISTAKES
  • Adding spaces in redirection operators
  • Misusing & instead of file descriptor numbers
  • Quoting filenames unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes