LFCS · Question #793
For which of the following can the tee command be used?
The correct answer is E. Send a command's output to stdout and a to file at the same time. The tee command is used to duplicate a command's standard output, sending it simultaneously to both the screen and one or more specified files.
Question
Options
- APrint the contents of a file in reverse order.
- BUse the output of one command as arguments to another.
- CAdd line numbers to the output of a command.
- DPipe the output of one command into the input of another.
- ESend a command's output to stdout and a to file at the same time.
How the community answered
(41 responses)- A5% (2)
- B2% (1)
- C5% (2)
- E88% (36)
Why each option
The `tee` command is used to duplicate a command's standard output, sending it simultaneously to both the screen and one or more specified files.
The `tee` command does not have functionality to reverse the order of file contents; commands like `tac` or `rev` are used for that.
Using command output as arguments for another command is typically achieved with backticks or `$(...)`, not the `tee` command.
Adding line numbers to command output is usually done with commands like `nl` or `cat -n`.
Piping the output of one command into the input of another is the general function of the `|` (pipe) operator, not specifically the `tee` command itself.
The `tee` command reads standard input and writes it to standard output (typically the screen) while also redirecting a copy of that same output to a file or multiple files, acting like a T-junction for data streams.
Concept tested: tee command functionality
Source: https://www.gnu.org/software/coreutils/manual/html_node/tee-invocation.html
Topics
Community Discussion
No community discussion yet for this question.