Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jan 2002 18:39:35 +0000
From:      Simon Siemonsma <simon.freebsd@hccnet.nl>
To:        adrian kok <adriankok2000@yahoo.com.hk>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: /dev/null 2>&1
Message-ID:  <200201151734.SAA01899@smtp.hccnet.nl>
In-Reply-To: <20020115171821.89227.qmail@web21208.mail.yahoo.com>
References:  <20020115171821.89227.qmail@web21208.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
The difference is that with Bourne Shells there are two types of output:
	the normal output
	errors
The way you sometimes do will redirect the standard output to the file 
buildworld.log.  The other way will also direct the errors to that file, 
instead of to the console. 

Simon Siemonsma

On Tuesday 15 January 2002 17:18, you wrote:
> Dear
>
> Thank you very much for your reply
>
> I also have question about it
>
> What is the advantage and the different
> /dev/null 2>&1
>
> Sometimes I only use this one
>
> make buildworld >buildworld.log
> not
> make buildworld >buildworld.log 2>&1 &
>
> Thank you again
>
>
>
>
>
> --- Giorgos Keramidas <keramida@freebsd.org> wrote: >
>
> On 2002-01-15 01:33:04, adrian kok wrote:
> > > Dear all
> > >
> > > What is the meaning of /dev/null 2>&1
> > >
> > > Thank you
> >
> > You'll see constructs like this in scripts that
> > read:
> >
> > 	command >/dev/null 2>&1
> >
> > That is a Bourne shell idiom (does not work in CSH
> > and friends), that
> > means ``redirect standard output to /dev/null'' and
> > then ``redirect
> > file-descriptor 2 (stderr) to the same place as 1
> > (stdout)''.
> >
> > The purpose of all this is to stop `command' from
> > producing *any* kind
> > of output, on standard output and error.
> >
> > Another use could be to save all output from a
> > command in a file, both
> > standard output and standard error.  I customarily
> > build my kernels
> > and update my FreeBSD systems with commands like
> > this:
> >
> > 	# cd /usr/src
> > 	# make buildworld >buildworld.log 2>&1 &
> > 	# logout
> >
> > Then after buildworld finishes ...
> >
> > 	# cd /usr/src
> > 	# make buildkernel >buildkernel.log 2>&1 &
> > 	# logout
> >
> > This way, all output from `make buildworld' is saved
> > in the file
> > /usr/src/buildworld.log and all output from `make
> > buildkernel' is
> > saved in /usr/src/buildkernel.log.  A few hours
> > later, I can browse
> > the file for interesting messages.
> >
> > Cheers,
> >
> > --
> > Giorgos Keramidas . . . . . . . . .
> > keramida@{ceid.upatras.gr,freebsd.org}
> > FreeBSD Documentation Project . . .
> > http://www.freebsd.org/docproj/
> > FreeBSD: The power to serve . . . .
> > http://www.freebsd.org/
> >
> >
> > ATTACHMENT part 2 application/pgp-signature
>
> _______________________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com.hk address at http://mail.english.yahoo.com.hk
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message

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




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