Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Oct 2002 18:50:18 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-stable@FreeBSD.ORG
Subject:   Re: New sed breaks ports
Message-ID:  <200210111650.g9BGoICR021531@lurza.secnetix.de>
In-Reply-To: <3DA5C638.10605@potentialtech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Bill Moran <wmoran@potentialtech.com> wrote:
 > On a related note, what is the shell magic to redirect
 > both stdout and stderr to a file, I though it was:
 > 
 > make REINPLACE_CMD="sed -i" 2>&1 > /dir/file.txt

The order of redirects matters.  When a redirect occurs on
a commandline, if uses the FDs (file descriptors) in effect
at that point.

"2>&1" connects FD 2 (stderr) to the file associated with
FD 1 (stdout).  In the above command, that's your terminal,
so stderr will be redirected to the terminal.  After that,
you redirect FD 1 (stdout) to file.txt.  Probably not what
you want.

Try it the other way round:

make REINPLACE_CMD="sed -i" >/dir/file.txt 2>&1

Now, first FD1 (stdout) is redirected to file.txt.  After
that, "2>&1" connects FD 2 (stderr) to the file associated
with FD 1 (stdout), which is now file.txt, so both of them
will end up in file.txt.  This is what you want, I guess.

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210111650.g9BGoICR021531>