Files
tldr/pages.zh/common/tee.md

20 lines
660 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# tee
> 从 `stdin` 读取并写入到 `stdout` 和文件(或命令)。
> 更多信息:<https://www.gnu.org/software/coreutils/tee>.
-`stdin` 复制到每个文件,并同时写入 `stdout`
`echo "example" | tee {{path/to/file}}`
- 追加到给定的文件,而不覆盖:
`echo "example" | tee -a {{path/to/file}}`
-`stdin` 打印到终端,同时将其传递给另一个程序以进行进一步处理:
`echo "example" | tee {{/dev/tty}} | {{xargs printf "[%s]"}}`
- 创建一个名为 "example" 的目录,计算 "example" 中的字符数量,并将 "example" 写入终端:
`echo "example" | tee >(xargs mkdir) >(wc -c)`