2019-04-21 11:50:48 +08:00

40 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="tee">tee</h1>
<p>把数据重定向到给定文件和屏幕上</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>tee命令</strong> 用于将数据重定向到文件另一方面还可以提供一份重定向数据的副本作为后续命令的stdin。简单的说就是把数据重定向到给定文件和屏幕上。</p>
<p>!</p>
<p>存在缓存机制每1024个字节将输出一次。若从管道接收输入数据应该是缓冲区满才将数据转存到指定的文件中。若文件内容不到1024个字节则接收完从标准输入设备读入的数据后将刷新一次缓冲区并转存数据到指定文件。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">tee(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-a向文件中重定向时使用追加模式
-i忽略中断interrupt信号。</code></pre>
<h3 id="参数">参数</h3>
<p>文件:指定输出重定向的文件。</p>
<p>在终端打印stdout同时重定向到文件中</p>
<pre><code class="language-bash">ls | tee out.txt
1.sh
1.txt
2.txt
eee.tst
EEE.tst
one
out.txt
string2
www.pdf
WWW.pdf
WWW.pef</code></pre>
<pre><code class="language-bash">[root@localhost text]# ls | tee out.txt | cat -n
1 1.sh
2 1.txt
3 2.txt
4 eee.tst
5 EEE.tst
6 one
7 out.txt
8 string2
9 www.pdf
10 WWW.pdf
11 WWW.pef</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->