Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Advanced Korn Question

RE: Advanced Korn Question

From: <jkstill_at_cybcon.com>
Date: Wed, 14 Mar 2001 11:21:06 -0800
Message-ID: <F001.002CC6C3.20010314082248@fatcity.com>

On Tue, 13 Mar 2001, hp wrote:

> can you tell mne what the difference is between:
> > $log 2>&1 &
> and
> 2>&1 > $log &
>
> if tried both ways and the std err and std out go to the log both ways.
>

Probably not, unless you have some strange variant of ksh.

When you redirect STDOUT with "> $log", STDOUT is no longer pointing to file descriptor 1, it is pointing to some new file descriptor.

Here's what happens when you redirect STDERR first:

  date -%sdfd 2>&1 >|date.txt

STDERR is redirected to STDOUT, which is file descriptor number 1. STDOUT is then redirected to some new file descriptor. STDERR from this command will not appear in the file "date.txt", but rather will appear on the screen, which is still file descriptor 1. Try it.

Now change it to this:

  date -%sdfd >|date.txt 2>&1

Now STDOUT is redirected first, and it is sent to some new file descriptor. When STDERR is next redirected, it will point at the new file descriptor for STDOUT, and the error output will appear in the file.

Jared

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: jkstill_at_cybcon.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Mar 14 2001 - 13:21:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US