Shell csh: Difference between redirections?

In csh shell, what's the differency between the following redirections?;

mycommand >>& "$log_file"

and

mycommand >> "$log_file" 2>&1
 
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. Therefore 2>&1 makes no sense for that shell. It always redirects both to the same place. From the man page
The 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.

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
 
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
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.
 
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,

I often enough do things, when not root, such as

% sh -c 'du -md2 / | sort -n 2>/dev/null' | less

which without redirecting stderr (fd 2) to null or a file will pepper output with 'permission denied' etc.

So the small inconvenience of wrapping these commands in sh -c '...' is worth it for me, for having the general interactive features of csh. IMHO, OC ..
 
Back
Top