Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-spam!mordor!styx!lll-lcc!pyramid!prls!mips!dce From: dce@mips.UUCP Newsgroups: comp.unix.questions Subject: Re: Stupid shell I/O redirection question... Message-ID: <192@quacky.mips.UUCP> Date: Tue, 24-Feb-87 23:47:23 EST Article-I.D.: quacky.192 Posted: Tue Feb 24 23:47:23 1987 Date-Received: Fri, 27-Feb-87 22:28:36 EST References: <612@rna.UUCP> <614@rna.UUCP> Reply-To: dce@quacky.UUCP (David Elliott) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 23 File descriptors can be handled very clearly and simply by using the fact that 'exec' with no command can be used to redirect file descriptors in the current shell. Let's say that you want to redirect standard error to a file and standard out to the old standard error. This can be done by exec 9>&1 # fd 9 is now a duplicate of stdout exec 1>&2 # stdout is now a duplicate of stderr 2>file command... # stderr goes to 'file' exec 1>&9 # stdout restored to original The idea is that you can save any file descriptor in one that isn't being used (9 is a good candidate since it stands out), and restore it at a later time. The Bourne shell has some very useful features hidden in it (I still am amazed at the prompt changing on the fly that is implemented using traps and an infinite loop sending signals). -- David Elliott UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!dce, DDD: 408-720-1700