Perhaps you should just try it?
> { echo out; echo err >&2; } >f1 2>&1
> cat f1
out
err
> { echo out; echo err >&2; } 2>&1 >f1
err
> cat f1
out
Redirection order definitely DOES matter in the shell. (Hmm, unless it's shell-specific? I'm using bash)
And just to do exactly what you said..
> perl -e'print "print\n"; warn "warn"' >f1 2>&1
> cat f1
warn at -e line 1.
print
> perl -e'print "print\n"; warn "warn"' 2>&1 >f1
warn at -e line 1.
> cat f1
print
In the first case both print and warn go to the file, in the second case warn goes to stdout and print to the file.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|