您好,登錄后才能下訂單哦!
今天小編給大家分享一下Linux tee命令怎么使用的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
Linux tee命令的功能是從標準輸入讀取,再寫入標準輸出和文件,其使用語法是“tee [OPTION]... [FILE]...”,其中參數(shù)“-a --append”表示追加到文件,參數(shù)“-i --ignore-interrupts”表示忽略中斷信號,參數(shù)“-p”表示診斷寫入非管道的錯誤等。
linux 命令:tee 詳解
tee 的功能是從標準輸入讀取,再寫入標準輸出和文件。
用法:tee [OPTION]... [FILE]...
-a, --append 追加到文件
-i, --ignore-interrupts 忽略中斷信號
-p 診斷寫入非管道的錯誤
--output-error[=MODE] 設置輸出錯誤的方式,MODE 的選項在下邊
--help 幫助文檔
--version 版本信息
MODE:
warn 寫入遇到錯誤時診斷
warn-nopipe 寫入非管道遇到錯誤時診斷
exit 寫入遇到錯誤時退出
exit-nopipe 寫入非管道遇到錯誤時退出
如果沒有指定 --output-error,tee 會在寫入管道發(fā)生錯誤時立即退出,寫入非管道時診斷。
使用示例:
默認功能和追加功能:
[root@server dir]# echo 'This is a sentence.' | tee output
This is a sentence.
[root@server dir]# cat output
This is a sentence.
[root@server dir]# echo 'This is another sentence.' | tee -a output
This is another sentence.
[root@server dir]# cat output
This is a sentence.
This is another sentence.
[root@server dir]# echo 'This is a unique sentence.' | tee output
This is a unique sentence.
[root@server dir]# cat output
This is a unique sentence.
同時寫入兩個文件:
[root@server dir]# tee a b
they have the same content
they have the same content
^C
[root@server dir]# cat a
they have the same content
[root@server dir]# cat b
they have the same content
以上就是“Linux tee命令怎么使用”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。