Bird
0
0

What does the 2> operator do in a bash script?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Error Handling
What does the 2> operator do in a bash script?
ARedirects error messages to a file
BRedirects standard output to a file
CAppends output to a file
DRuns a command in the background
Step-by-Step Solution
Solution:
  1. Step 1: Understand bash output streams

    Bash has two main output streams: standard output (1) and standard error (2).
  2. Step 2: Identify the meaning of 2>

    The operator 2> redirects the standard error stream to a file or location.
  3. Final Answer:

    Redirects error messages to a file -> Option A
  4. Quick Check:

    2> means error redirect [OK]
Quick Trick: Remember 2 is error stream, so 2> redirects errors [OK]
Common Mistakes:
MISTAKES
  • Confusing 2> with > which redirects standard output
  • Thinking 2> appends instead of overwriting
  • Assuming 2> runs commands in background

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes