2018-11-15 16:30:55 +00:00
|
|
|
---
|
|
|
|
layout: page
|
2018-11-16 12:47:48 +00:00
|
|
|
category-page: intermediate
|
|
|
|
category-title: Intermediate commands
|
|
|
|
tags: tee output save
|
2018-11-15 16:30:55 +00:00
|
|
|
author: Nicola Brunner
|
|
|
|
title: tee
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/cmd/interm/tar.html
|
|
|
|
next-page: pages/cmd/interm/watch.html
|
2018-11-15 16:30:55 +00:00
|
|
|
---
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
The <code>tee</code> command is used to split the output of a program, doing
|
2018-11-15 16:30:55 +00:00
|
|
|
this the output can be displayed in the shell and in the same time written in a
|
|
|
|
file. This is useful, for example, if we want to capture intermediate outputs of
|
|
|
|
a long program.
|
|
|
|
The command is named after the T-splitter used in plumbing, because they have
|
2018-11-15 20:09:21 +00:00
|
|
|
similar functions.<br>
|
2018-11-15 16:30:55 +00:00
|
|
|
|
|
|
|
<h3>Usage:</h3>
|
2018-11-15 20:09:21 +00:00
|
|
|
The default tee command syntax is:
|
2018-11-15 16:30:55 +00:00
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
<pre>
|
|
|
|
tee [flags] [file]
|
|
|
|
</pre>
|
2018-11-15 16:30:55 +00:00
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
Where <code>[flags]</code> are the tee flags (below you will find more info),
|
2018-11-15 16:30:55 +00:00
|
|
|
and argument <code>[file]</code> is a file or a list of files, each of which
|
2018-11-15 20:09:21 +00:00
|
|
|
receives the output.<br>
|
2018-11-15 16:30:55 +00:00
|
|
|
|
|
|
|
<h3>Flags:</h3>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>-a</code> Appends the output to each file, rather than overwriting it.</li>
|
|
|
|
<li><code>-i</code> Ignores interrupt signals.</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h3>Example:</h3>
|
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
<pre>
|
|
|
|
date | tee example.txt
|
|
|
|
</pre>
|
2018-11-15 16:30:55 +00:00
|
|
|
|
2018-11-15 20:09:21 +00:00
|
|
|
With this example, we can see that tee writes the date in
|
|
|
|
<i>example.txt</i>, but shows also the output (in this case the date) in the shell.
|
|
|
|
If you would prefer to have content appended instead of overwritten on the file,
|
|
|
|
should use <code>-a</code> flag on <code>tee</code>.
|