在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更多推荐
发布评论