Bird
0
0

You want to save both standard output and standard error of a script to separate files but also see standard output on the screen. Which command achieves this?

hard🚀 Application Q8 of 15
Bash Scripting - File Operations in Scripts
You want to save both standard output and standard error of a script to separate files but also see standard output on the screen. Which command achieves this?
Ascript.sh > >(tee stdout.log) 2> stderr.log
Bscript.sh > stdout.log 2> stderr.log
Cscript.sh &> stdout.log
Dscript.sh > stdout.log 2>&1
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirements

    Standard output should be saved and displayed; standard error saved separately.
  2. Step 2: Analyze options

    script.sh >(tee stdout.log) 2> stderr.log uses process substitution with tee to show and save stdout, stderr redirected separately.
  3. Final Answer:

    script.sh >(tee stdout.log) 2> stderr.log -> Option A
  4. Quick Check:

    Use tee with process substitution to split stdout [OK]
Quick Trick: Use tee with process substitution to split output [OK]
Common Mistakes:
MISTAKES
  • Redirecting both streams to same file
  • Using &> which merges outputs
  • Not showing stdout on screen

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes