[英]linux terminal: how to copy output to a file and print at terminal simultaneously?
[英]Print on terminal and into file simultaneously?
我有一個shell腳本來壓縮一些數據..我想將結果打印到一個文件中,但這樣做會阻止結果顯示在終端上。 有沒有一種方法可以在屏幕上打印結果並寫入文件。 提前致謝。
將輸出傳遞給tee
命令。
例:
[me@home]$ echo hello | tee out.txt
hello
[me@home]$ cat out.txt
hello
請注意, echo
的stdout將打印出來並寫入thr tee
命令指定的文件中。
請注意,您可以將-a
標志添加到tee
以附加到輸出文件
[me@home]$ echo hello | tee out.txt
hello
[me@home]$ echo hello again | tee -a out.txt
hello again
[me@home]$ cat out.txt
hello
hello again
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.