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!
The regular output is sent to Standard Out (STDOUT) and the error messages are sent to Standard Error (STDERR). When you redirect console output using the > symbol, you are only redirecting STDOUT. In order to redirect STDERR, you have to specify 2> for the redirection symbol.
$ echo “Hello” > hello. txt The > command redirects the standard output to a file. Here, “Hello” is entered as the standard input, and is then redirected to the file **…
&>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With