Ama*_*man 30 command-line bash tee
我知道要在处理的中间阶段捕获管道的内容,我们使用 tee as ls /bin /usr/bin | sort | uniq | tee abc.txt | grep out
,但是如果我不想将uniq 之后 的内容重定向到 abc.txt而是 要筛选(通过 stdout,当然),以便作为最终结果,我将在屏幕上显示 uniq 之后的中间内容以及 grep 之后的内容。
JJo*_*oao 41
有时 /dev/tty 可用于...
ls /bin /usr/bin | sort | uniq | tee /dev/tty | grep out | wc
Run Code Online (Sandbox Code Playgroud)
ls /bin /usr/bin | sort | uniq | tee /dev/fd/2 | grep out | wc
Run Code Online (Sandbox Code Playgroud)
在 Linux 系统上,您可以/dev/fd/[num]
在许多情况下使用像命名管道这样的链接。这会将 stdout 复制到 stderr,它通常是您的终端screen,但不一定是。