A system administrator is running a lengthy script, ./update.sh, that generates important progress information to standard output. The administrator needs to capture this output in a file named update.log for later analysis, but also wants to monitor the script's execution in real time on the terminal. Which of the following commands will achieve this?
The correct command is ./update.sh | tee update.log. The tee command reads from standard input and writes to both standard output and one or more files simultaneously. The pipe symbol | sends the standard output of the ./update.sh script to the standard input of the tee command. tee then displays that output on the terminal (its standard output) and saves it to the update.log file.
The command ./update.sh > update.log uses the output redirection operator >, which sends the standard output only to the file, not to the screen.
The command ./update.sh > update.log && tail -f update.log would only run tail -f after the ./update.sh script has finished successfully, which does not allow for real-time monitoring of the script as it runs.
The command tee update.log < ./update.sh incorrectly tries to use the script file itself as standard input for tee, rather than executing the script and capturing its output.
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.
What does the `tee` command do in Linux?
Open an interactive chat with Bash
What is the difference between `>` and `|` in Linux?
Open an interactive chat with Bash
How does `tail -f` differ from using `tee` for real-time monitoring?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access