![](/img/trans.png)
[英]How to redirect printf log to a specific file for a daemon process in Linux?
[英]linux : how to redirect to a file and to another process
我的命令如下
cmd1 | cmd2 | cmd3
我需要先查看命令輸出,然后再將其傳遞給另一個進程。 我怎樣才能做到這一點?
如果我用
cmd1 > file1 | cmd2 | cmd3
我想我必須在cmd2的過程中管理從文件讀取,但是我想要的是傳遞的標准輸出引發不同的命令,並查看傳遞的異常。
看一下tee
命令。 這可能是您要尋找的。 例:
cmd1 | tee file1 | cmd2 | cmd3
如前所述,您可以在執行的命令之間將tee
與/dev/tty
用作其參數:
ls -l | tee /dev/tty | grep one_file -A2 | tee /dev/tty | grep something_else
您可以使用tee
命令:
tee - read from standard input and write to standard output and files
例:
echo hi | tee 1.txt | cat -n | tee 2.txt | grep hi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.