Difficulty: Easy
Correct Answer: tee
Explanation:
Introduction / Context:
Sometimes you need to keep a record of command output while still monitoring it on screen. The tee utility solves this by duplicating standard output—writing to both a file and the terminal—making it invaluable for logging and troubleshooting pipelines.
Given Data / Assumptions:
Concept / Approach:
The syntax is cmd | tee file. By default, tee overwrites the file; use tee -a file to append. tee acts as a T-junction in a pipeline: it passes input through to standard output and also writes it to the named file(s).
Step-by-Step Solution:
Verification / Alternative check:
Run ls -lR / | tee listing.txt. Observe output on screen and verify listing.txt contains the same data. Re-run with -a to append additional listings without truncating previous content.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting -a when you intend to append; accidentally overwriting existing logs; misunderstanding that tee only captures what is piped into it (stdout), not stderr unless you redirect stderr to stdout (for example, 2>&1).
Final Answer:
tee
Discussion & Comments