Bird
0
0

Identify the error in this command that attempts to redirect only standard error to error.log:

medium📝 Debug Q14 of 15
Bash Scripting - File Operations in Scripts
Identify the error in this command that attempts to redirect only standard error to error.log:

ls -l > error.log 2>
AOutput redirection > should be 1>
BMissing filename after 2> for error redirection
CShould use 2>&1 instead of 2>
DCommand syntax is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check error redirection syntax

    Redirection 2> must be followed by a filename to redirect standard error.
  2. Step 2: Identify missing filename

    The command ends with 2> but no file is specified, causing a syntax error.
  3. Final Answer:

    Missing filename after 2> for error redirection -> Option B
  4. Quick Check:

    2> needs a target file [OK]
Quick Trick: Always specify a file after 2> for error redirection [OK]
Common Mistakes:
MISTAKES
  • Leaving out filename after 2>
  • Confusing 2> with 2>&1
  • Thinking > needs to be 1>

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes