Tee 使用場景

Tee命令用來同時(shí)存儲和展示其他命令的輸出

1. 輸出到Console同時(shí)寫入文件

使用ls查看文件夾下內(nèi)容:

$ ls
account  cache  crash 

同時(shí)需要保存到文件filelist.txt(否者需要ls > filelist.txt):

$ ls | tee filelist.txt
account
cache
crash
filelist.txt

查看filelist.txt中,會看到包含了上一條命令的輸出:

2. 輸出使用在多條命令中:

查看并備份當(dāng)前crontab后,更新crontab內(nèi)容(old->new)

$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab
3. 使用append(默認(rèn)覆蓋)
$ ls | tee –a file

4, 多文件寫

$ ls | tee file1 file2 file3
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容