Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Nov 1997 16:54:16 -0500 (EST)
From:      "Adrian T. Filipi-Martin" <atf3r@cs.virginia.edu>
To:        Jacques Hugo <jacques@wired.ctech.ac.za>
Cc:        questions@freebsd.org
Subject:   Re: 2>&1 ???
Message-ID:  <Pine.SOL.3.96.971128164445.4732A-100000@mamba.cs.Virginia.EDU>
In-Reply-To: <347E7CEE.41C67EA6@wired.ctech.ac.za>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 28 Nov 1997, Jacques Hugo wrote:

> Hi there ...
> 
> What exacltly does this means under sh/bash:
> 	do something 2>&1 wherever.
> 
> What does the 2>&1 do and where can you use
> other vatiations with it?

	>& is a redirection operator of the shell, just like >, <, |, etc.
${fd1}>&${fd2} duplicates the output file descriptor on the right, ${fd2},
onto the file descriptor on the left, ${fd1}.  Thus, 2>&1, duplictes the
stdout file descriptor onto the stderr one.  The net result is that
anything your redirected pogram writes to stderr/2 will actually appear on
stdout/1.

	This is useful if you have error output and you want to use a
pager like more or less.  e.g.  "patch -p < patchfile 2>&1 | more".


	You can find more in the bash manpage under "REDIRECTION" section.
You might also take a look at the dup2(2) man page.

> Thanks 
> -Jacques
> 
> ------------------------------------------------------
> The box said "Requires Windows 3.1 or better"
> 			... so I got BSD
			          ^^^^^ hehe.  cute!

	Adrian
--
adrian@virginia.edu        ---->>>>| If I were stranded on a desert island, and
System Administrator         --->>>| I could only have one OS for my computer,
Neurosurgical Visualzation Lab -->>| it would be FreeBSD.  Think about it.....
http://www.nvl.virginia.edu/     ->|      http://www.freebsd.org/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.3.96.971128164445.4732A-100000>