The command below writes READY to standard output and WARN to standard error.
The standard-error redirection is applied before the pipe.
bash -c 'printf "READY\n"; printf "WARN\n" >&2' \
2>errors.log | tee output.logWhich combination correctly describes the terminal and the two files?
A pipe carries standard output only. Standard error is sent to errors.log by 2>, while tee writes READY to both the terminal and output.log.
Detailed explanation
Correct. READY goes through tee to the terminal and output.log; WARN goes to errors.log via 2>.
Correct. READY goes through tee to the terminal and output.log; WARN goes to errors.log via 2>.
Incorrect. WARN is not part of the pipe because it is standard error.
Incorrect. WARN is not part of the pipe because it is standard error.
Incorrect. The terminal receives READY from tee, not WARN.
Incorrect. The terminal receives READY from tee, not WARN.
Incorrect. tee also writes to standard output, so the terminal is not empty.
Incorrect. tee also writes to standard output, so the terminal is not empty.
Try it yourself
An example you can run in a temporary verification environment.
bash -c 'printf "READY\n"; printf "WARN\n" >&2' \
2>errors.log | tee output.log
printf '%s\n' '--- output.log ---'
cat output.log
printf '%s\n' '--- errors.log ---'
cat errors.logExpected result
READY
--- output.log ---
READY
--- errors.log ---
WARNKey points
- File descriptors 1 and 2
- A pipe carries standard output only
- tee writes to the screen and a file
Notes
- Environment:
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.