Skip to Content
Small, Sharp Software Tools
book

Small, Sharp Software Tools

by Brian P. Hogan
June 2019
Intermediate to advanced
328 pages
7h 27m
English
Pragmatic Bookshelf
Content preview from Small, Sharp Software Tools

Splitting Streams with tee

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The VimL Primer

The VimL Primer

Benjamin Klein
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781680507003Errata Page