boris boris - 7 months ago 22
Ruby Question

Why can't I (or how can I) save the output of brew doctor with pipes?

I'm not sure just how specific this is, but when I run 'brew doctor' I see some error messages. If I want to save those messages I run

brew doctor > brewErrors.txt
. I see the errors in my terminal but if I
cat brewErrors.txt
I just get a file with a few inlines. Is this a more general issue (say of Ruby or some kind of library/method of reporting) or a super narrow one? And for the future, if I ever encounter this how can I work around/fix this?


Exactly how you fix this depends on your shell. But the problem is that > redirects STDOUT and generally error messages appear on STDERR. Every unix process has 3 file descriptors open by default (STDIN, STDOUT, STDERR).

This is how you would run the command to save STDERR to a file in bash.

How to redirect both stdout and stderr to a file