[Techtalk] Using > to redirect standard error?
John Clarke
johnc+linuxchix at kirriwa.net
Wed Jan 14 15:25:42 EST 2004
On Tue, Jan 13, 2004 at 07:01:47 -0800, Rachel McConnell wrote:
> So I've come up with the theory that there are two outputs which both
> normally print to console, call them stdout and stderr. > appears to
> redirect stdout, but not stderr.
You're right. If you're using a bash (or sh, but not csh) shell:
command > file redirects stdout to 'file'
command 2> file redirects stderr (file descriptor 2) to 'file'
command > file 2>&1 redirects both stdout and stderr to 'file'
This is a function of the shell, not the o/s, so it will work on
cygwin. For csh:
command > file redirects stdout to 'file'
command >& file redirects both stdout and stderr to 'file'
You can't redirect only stderr in csh.
Cheers,
John
--
whois !JC774-AU at whois.aunic.net
GPG key id: 0xD59C360F
http://kirriwa.net/john/
More information about the Techtalk
mailing list