在執(zhí)行Linux命令時(shí),我們既想把輸出保存到文件中,又想在屏幕上看到輸出內(nèi)容,就可以使用tee命令
要注意的是:在使用管道線時(shí),前一個(gè)命令的標(biāo)準(zhǔn)錯(cuò)誤輸出不會(huì)被tee讀取。
$ man tee
NAME
tee - read from standard input and write to standard output and files
SYNOPSIS
tee [OPTION]... [FILE]...
DESCRIPTION
Copy standard input to each FILE, and also to standard output.
-a, --append
append to the given FILEs, do not overwrite
-i, --ignore-interrupts
ignore interrupt signals
--help display this help and exit
--version
output version information and exit
If a FILE is -, copy again to standard output.
常見用例:
tee file //覆蓋
tee -a file //追加
tee - //輸出到標(biāo)準(zhǔn)輸出兩次
tee - - //輸出到標(biāo)準(zhǔn)輸出三次
tee file1 file2 - //輸出到標(biāo)準(zhǔn)輸出兩次,并寫到那兩個(gè)文件中
ls | tee file
另:把標(biāo)準(zhǔn)錯(cuò)誤也被tee讀取
ls '*' 2>&1 | tee ls.txt
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。