Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zsh pipe all output to command

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!

like image 290
Christopher Shroba Avatar asked Jul 29 '15 15:07

Christopher Shroba


People also ask

How do I redirect standard output?

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.

How do I redirect an echo to a file?

$ 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 **…


1 Answers

&> 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
like image 62
chepner Avatar answered Oct 13 '22 10:10

chepner