From owner-freebsd-questions Tue Jan 15 12:27:51 2002 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 9731F37B41D for ; Tue, 15 Jan 2002 12:27:47 -0800 (PST) Received: from [212.238.194.207] (helo=tanya.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16QaBO-000Ko5-00 for questions@FreeBSD.ORG; Tue, 15 Jan 2002 20:27:46 +0000 Received: by tanya.raggedclown.net (tanya.raggedclown.intra, from userid 500) id B05CF1186; Tue, 15 Jan 2002 21:27:45 +0100 (CET) Date: Tue, 15 Jan 2002 21:27:45 +0100 From: Cliff Sarginson To: questions@FreeBSD.ORG Subject: Re: /dev/null 2>&1 Message-ID: <20020115202745.GB7588@raggedclown.net> References: <20020114174940.72104.qmail@web21210.mail.yahoo.com> <5.1.0.14.0.20020114115025.0372fe90@pop3s.schulte.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5.1.0.14.0.20020114115025.0372fe90@pop3s.schulte.org> User-Agent: Mutt/1.3.24i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Jan 14, 2002 at 11:53:39AM -0600, Christopher Schulte wrote: > At 01:49 AM 1/15/2002 +0800, adrian kok wrote: > >Hi Zaa > > > >Thank you. But what is the purpose for it on the > >system? > > Often when a command ( compile or cron job, for example ) wants to restrict > certain output. In such cases the output might: confuse the user, add > jabber to the console, or generate unwanted email messages. > > >>for example, if you type > > > >>find / -name foo > /dev/null 2>&1 > > > >is seems that stdin is redirected to nowhere > >(/dev/null) > >and stderr is redirected to stdout e.g to /dev/null > >too > Yup. Order is important. Doing the above the opposite way around has a different effect. find / -name foo 2>&1 >/dev/null Will first redirect stderr to stdout, which at that moment is directed to the terminal (well, or wherever it will be going to if it is run under cron etc.). Then standard output is redirected to /dev/null. Stderr however remains directed at what the standard error *was* pointing at. The commands are evaluated from left to right -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message