send stderr to a file and also to stdout
Hi,
If i am running some program, say make, and want all that is printed to stderr(but not stdout) also to go to a file (and get printed on the stdout as well), how do i do it? I found 'tee', bit i am looking for its stderr counterpart!! thanks, pranav |
If you don't need the stdout messages, you could do:
Code:
make 2>&1 >/dev/null | tee your_file Alternatively, you might consider named FIFO pipes. See "man mkfifo". And there is no "stderr counterpart" to tee. tee just copies whatever it gets on it's stdin to it's stdout and to a file. What it gets on it's stdin can come from anywhere (another programs stdout, stderr, a file, ...). |
Hi,
make 3>&1 1>&2 2>&3 | tee stderr.txt The above will: Show normal text on screen, Show error text on screen, Put error text in file. This is done by reassigning your file descriptors stdout will become stderr and stderr will become stdout. tee (which only works in stdout) will put the reassigned stderr to file. Hope this is what you are looking for. |
The idea of reassigning stderr to stdout and vice-versa works.
Thanks, Pranav |
I am trying the same command...in a c-shell script and it doesn't work...
!#/bin/csh -f make 3>&1 1>&2 2>&3 | tee build.err It gives 'ambiguous output redirect" error.. the only thing that works in a c-shell is this.. make >& build.err which puts both stdout and stderr in a file. I could not find a way to just redirect stderr to a file and not both. any suggestions ? -mjr |
Hi,
Too my knowledge this cannot be done with (t)csh. Hope this clears things up. |
Well... I figured out something of a workaround to put stdout and stderr in different files when
using a C-shell. ( make > build.out ) >& build.err this works. any other suggestions.. -mjr |
This information was very useful. Thanks!
|
All times are GMT -5. The time now is 05:43 PM. |