Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Unix 环境中,我想使用tee如下命令链:
tee
$ echo 1; echo 2 | tee file 1 2 $ cat file 2
为什么file最终只有最终命令的输出?
file
出于讨论的目的,假设我不能将它们分开并单独运行命令。
它只有第二个命令的输出,因为分号表示 shell 的新语句。
只需将它们放在括号中:
(echo 1; echo 2) | tee file
尝试:
( echo 1; echo 2 ) | tee file
没有括号,它被解析为:
echo 1 ; ( echo 2 | tee file )