An administrator is writing a shell script where the output of a command needs to be both displayed on the screen and written to a file for logging purposes. Which command and operator should the administrator use to achieve this?
You selected this option
Redirecting output using the > operator
You selected this option
Piping the output to another command with the | operator
You selected this option
Using the tee command with the | operator
You selected this option
Appending the output to a file using the >> operator
The 'tee' command is the right choice for this task because it reads from standard input and writes to both standard output (allowing the user to see the output on the screen) and one or more files, essentially duplicating the output stream. The operator > is used to redirect output to a file but does not display it on the screen. The operator | is used to pipe the output of one command to another but on its own does not write to a file. The operator >> is used to append output to a file but again, it does not display the output on the screen.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
How does the 'tee' command work in detail?
Open an interactive chat with Bash
What is the difference between the '>' and '>>' operators?