linux命令之tee

來源:互聯網
上載者:User

linux命令之tee

名稱:tee

位置:/usr/bin/tee

許可權:所有使用者

作用:雙向重新導向,會同時將資料流送與檔案和螢幕;而輸出到螢幕的,就是stdout,可以讓下一下命令繼續處理。

用法:tee [OPTION]... [FILE]...

選項:

-a, --append append to the given FILEs, do not overwrite

追加

雙向重新導向,在寫入檔案last.list之後,還能輸出到螢幕上。

last |tee last.listcwjy1202 pts/0        :0               Sat Jan 10 22:14   still logged in   reboot   system boot  3.2.0-24-generic Sat Jan 10 21:45 - 23:02  (01:16)    cwjy1202 pts/0        :0.0             Sat Jan 10 19:24 - down   (00:00)    reboot   system boot  3.2.0-24-generic Sat Jan 10 14:17 - 19:24  (05:07)    reboot   system boot  3.2.0-24-generic Fri Jan  9 20:50 - 22:50  (01:59)    cwjy1202 pts/0        :0               Thu Jan  8 22:08 - 23:16  (01:08)    reboot   system boot  3.2.0-24-generic Thu Jan  8 21:45 - 23:17  (01:31)    cwjy1202 pts/2        :0               Wed Jan  7 23:22 - 00:27  (01:05)    cwjy1202 pts/0        :0               Wed Jan  7 23:04 - 00:27  (01:23)    reboot   system boot  3.2.0-24-generic Wed Jan  7 23:03 - 00:27  (01:23)    cwjy1202 pts/2        :0               Tue Jan  6 23:10 - 23:46  (00:36)    cwjy1202 pts/0        :0               Tue Jan  6 22:32 - 23:46  (01:13)    reboot   system boot  3.2.0-24-generic Tue Jan  6 19:32 - 23:46  (04:13)    cwjy1202 pts/0        :0               Tue Jan  6 00:24 - 00:46  (00:21)    reboot   system boot  3.2.0-24-generic Mon Jan  5 20:59 - 00:46  (03:47)    cwjy1202 pts/0        :0               Sat Jan  3 20:33 - 00:39  (04:06)    cwjy1202 pts/0        :0               Sat Jan  3 19:23 - 19:24  (00:00)    reboot   system boot  3.2.0-24-generic Sat Jan  3 19:12 - 00:41  (05:28)    cwjy1202 pts/2        :0               Sat Jan  3 14:58 - 17:04  (02:05)    cwjy1202 pts/1        :0               Sat Jan  3 14:57 - 17:04  (02:07)    reboot   system boot  3.2.0-24-generic Sat Jan  3 14:54 - 17:05  (02:10)    wtmp begins Fri Jan  2 17:17:32 2015
注意:上名的tee命令並沒有加選項 -a,這樣預設檔案將會被覆蓋。

下面的例子,last的資訊在寫入檔案last.list,同時還能被sed 命令處理

$ last |tee  -a last.list| sed -n '1p'cwjy1202 pts/0        :0               Sat Jan 10 22:14   still logged in 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.