On Tue, Apr 01, 2003 at 09:44:19AM +1000, Martin wrote:
: $author = "Bernie Pannell" ;
: > 
: > > root preexec = /bin/mount /bigdisk 2>&1 >> /tmp/bigdisk-mount.log
: > 
: > I've usually put 2>&1 *after* the output file name, eg:
: >   command >> logfile 2>&1
: > 
: > Is there some difference either way?
: 
: from man bash:
: 
:   Note that the order of redirections is significant.  For example, the
:   command
: 
:     ls > dirlist 2>&1
: 
:   directs both standard output and standard error to the file dirlist, while

because it does the > in order stated

        ls stdout to dirlist
        ls stderr same as stdout

:   the command
: 
:     ls 2>&1 > dirlist
: 
:   directs only the standard output to file dirlist, because the standard
:   error was duplicated as standard output before the standard output was
:   redirected to dirlist.

also does the > in order stated

        ls stderr same as current stdout (probably /dev/tty)
        ls stdout to dirlist, leaving stderr as already set

Note however that mixing | and > is not strictly left to right, in that

        ls 2>&1 | wc

is effectively

        make ls stdout go to wc stdin
        make ls stderr same as ls stdout

so the | is done *before* the >&

-- 
Christopher Vance
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to