我希望能夠重定向stdout到stderr但也保留其中的內容stdout。所以不完全重定向而是cloneor duplicate。
uj5u.com熱心網友回復:
通常:
command | tee /dev/stderr
uj5u.com熱心網友回復:
找到了解決方案:
mycommand | awk '{print; print | "cat 1>&2"}' > /tmp/stdout-content
# and stout is also in stderr (visible in the terminal)
uj5u.com熱心網友回復:
如果唯一的目的是將標準輸出拆分到終端和檔案,另一個想法:
mycommand | tee -a /tmp/stdout-content
注意: -a說要附加到檔案中;要在每次mycommand運行時覆寫檔案,您可以洗掉-a(這會讓您得到與 KamilCuk 剛剛發布的內容相同的內容)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/455231.html
下一篇:基于引數的Bash計數出現
