When I run the following command in csh
, I got nothing, but it works in bash
.
Is there any equivalent in csh
which can redirect the standard error to standard out?
somecommand 2>&1
This question is related to
io-redirection
csh
As paxdiablo said you can use >&
to redirect both stdout and stderr. However if you want them separated you can use the following:
(command > stdoutfile) >& stderrfile
...as indicated the above will redirect stdout to stdoutfile and stderr to stderrfile.
I object the above answer and provide my own. csh
DOES have this capability and here is how it's done:
xxx |& some_exec # will pipe merged output to your some_exec
or
xxx |& cat > filename
or if you just want it to merge streams (to stdout) and not redirect to a file or some_exec:
xxx |& tee /dev/null
What about just
xxx >& /dev/stdout
???
xxx >& filename
Or do this to see everything on the screen and have it go to your file:
xxx | & tee ./logfile
I think this is the correct answer for csh.
xxx >/dev/stderr
Note most csh are really tcsh in modern environments:
rmockler> ls -latr /usr/bin/csh
lrwxrwxrwx 1 root root 9 2011-05-03 13:40 /usr/bin/csh -> /bin/tcsh
using a backtick embedded statement to portray this as follows:
echo "`echo 'standard out1'` `echo 'error out1' >/dev/stderr` `echo 'standard out2'`" | tee -a /tmp/test.txt ; cat /tmp/test.txt
if this works for you please bump up to 1. The other suggestions don't work for my csh environment.
Source: Stackoverflow.com