Linux命令之tee命令使用實(shí)例
名稱:tee
位置:/usr/bin/tee
權(quán)限:所有用戶
作用:雙向重定向,會(huì)同時(shí)將數(shù)據(jù)流送與文件和屏幕;而輸出到屏幕的,就是stdout,可以讓下一下命令繼續(xù)處理。
用法:tee [OPTION]... [FILE]...
選項(xiàng):
-a, --append append to the given FILEs, do not overwrite
追加
雙向重定向,在寫入文件last.list之后,還能輸出到屏幕上。
last |tee last.list
cwjy1202 pts/0 :0Sat Jan 10 22:14still logged in
rebootsystem 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)
rebootsystem boot 3.2.0-24-generic Sat Jan 10 14:17 - 19:24 (05:07)
rebootsystem boot 3.2.0-24-generic Fri Jan 9 20:50 - 22:50 (01:59)
cwjy1202 pts/0 :0Thu Jan 8 22:08 - 23:16 (01:08)
rebootsystem boot 3.2.0-24-generic Thu Jan 8 21:45 - 23:17 (01:31)
cwjy1202 pts/2 :0Wed Jan 7 23:22 - 00:27 (01:05)
cwjy1202 pts/0 :0Wed Jan 7 23:04 - 00:27 (01:23)
rebootsystem boot 3.2.0-24-generic Wed Jan 7 23:03 - 00:27 (01:23)
cwjy1202 pts/2 :0Tue Jan 6 23:10 - 23:46 (00:36)
cwjy1202 pts/0 :0Tue Jan 6 22:32 - 23:46 (01:13)
rebootsystem boot 3.2.0-24-generic Tue Jan 6 19:32 - 23:46 (04:13)
cwjy1202 pts/0 :0Tue Jan 6 00:24 - 00:46 (00:21)
rebootsystem boot 3.2.0-24-generic Mon Jan 5 20:59 - 00:46 (03:47)
cwjy1202 pts/0 :0Sat Jan 3 20:33 - 00:39 (04:06)
cwjy1202 pts/0 :0Sat Jan 3 19:23 - 19:24 (00:00)
rebootsystem boot 3.2.0-24-generic Sat Jan 3 19:12 - 00:41 (05:28)
cwjy1202 pts/2 :0Sat Jan 3 14:58 - 17:04 (02:05)
cwjy1202 pts/1 :0Sat Jan 3 14:57 - 17:04 (02:07)
rebootsystem boot 3.2.0-24-generic Sat Jan 3 14:54 - 17:05 (02:10) </p> <p>wtmp begins Fri Jan 2 17:17:32 2015</p> <p>
注意:上名的tee命令并沒有加選項(xiàng) -a,這樣默認(rèn)文件將會(huì)被覆蓋。
下面的例子,last的信息在寫入文件last.list,同時(shí)還能被sed 命令處理
$ last |tee -a last.list| sed -n '1p'
cwjy1202 pts/0 :0Sat Jan 10 22:14still logged in
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。