2>&1
makes no sense for that shell. It always redirects both to the same place. From the man pageThe shell cannot presently redirect diagnostic output without also
redirecting standard output, but `(command > output-file) >& error-
file' is often an acceptable workaround.
There's no way to split out stderr from stdout in csh(1). It's one of the reasons why I don't use it.
sh -c 'command 2>&1 >> logfile'
sh -c 'command 2>/dev/null >somefile' # or >>somefile
My reading of the man page is that the number "2" is not necessary in these redirections. Typically a process in a Unixy environment automatically gets two file descriptors opened for it. File descriptor 1 is standard output, and 2 is standard error, though the csh man page calls the latter "diagnostic output". Those are the literal integer values of the file handles. I guess this is why Bourne shells use 2 to redirect stderr. I guess 1 for stdout is the default value.Redirection is the only issue I have with interactive csh, but it's simple enough to deal with e.g:
sh -c 'command 2>&1 >> logfile'
and especially to omit stderr:
sh -c 'command 2>/dev/null >somefile' # or >>somefile
Yep. The 2>& 1 >> logfile basically say redirect stderr to stdout and then redirect stdout to logfile.I guess 1 for stdout is the default value.
There's no way to split out stderr from stdout in csh(1).
You can use a sub-shell.Redirection is the only issue I have with interactive csh
( ( echo ok ; '' ) > file ) >& err )
( ( ( echo ok ; '' ) > /dev/fd/0 ) >& err < /dev/fd/1 ) | sed '$s/$/\nok/'
My reading of the man page is that the number "2" is not necessary in these redirections. Typically a process in a Unixy environment automatically gets two file descriptors opened for it. File descriptor 1 is standard output, and 2 is standard error,
% sh -c 'du -md2 / | sort -n 2>/dev/null' | less