June 2019
Intermediate to advanced
328 pages
7h 27m
English
When you redirect the output to a file, it no longer displays on the screen. To see the output on the screen and send it to a file, you could use the cat or less commands to view the file, but you can also use the tee command. The tee command gets its name from plumbing—a T-shaped pipe fitting that splits the water off in two directions. The tee command takes input and splits the stream to the screen and to a file.
Execute the history command and pipe its data to the tee command:
| | $ history | tee commands.txt |
Instead of redirecting the output to a file, you’re piping it to tee, which receives the data as standard input. This time, you see the results on the screen. The commands.txt file will also have ...