Zsh管道输出所有命令(Zsh pipe all output to command)

编程入门 行业动态 更新时间:2024-10-26 20:34:17
Zsh管道输出所有命令(Zsh pipe all output to command)

在Zsh中,我知道你可以通过command &> file.txt将所有文件描述符传送到file.txt(而不是像command 2>&1 3>&1 > file.txt那样单独执行每个文件描述符,如果你有三个文件描述)。 有没有办法将所有文件描述符管到另一个命令? 如command <mystery operator> cat ?

编辑:我错了,正如切普纳和伊坦指出的那样; &>只重定向fd的1和2.谢谢!

In Zsh, I know you can do command &> file.txt to pipe all file descriptors to file.txt (rather than having to do each file descriptor individually like command 2>&1 3>&1 > file.txt if you had three file descriptors). Is there a way to pipe all file descriptors to another command? such as command <mystery operator> cat?

Edit: I was wrong, as Chepner and Etan pointed out; &> only redirects fd's 1 and 2. Thanks!

最满意答案

&>仅重定向标准输出和标准错误,而不是该command可能写入的所有文件描述符。 但是,等效的管道是

command |& grep # Equivalent to command 2>&1 | grep

&> only redirects standard output and standard error, not all file descriptors that command might write to. The equivalent pipe, though, is

command |& grep # Equivalent to command 2>&1 | grep

更多推荐

本文发布于:2023-08-08 01:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466729.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:管道   命令   Zsh   command   output

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!