Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Redirection in the middle of a script?



On Sep 30, 12:04am, Jahwan Kim wrote:
} Subject: Redirection in the middle of a script?
}
}     I have this long-standing question, which I can't find an answer to,
} perhaps because it's impossible.  Is it possible to redirect
} STDOUT/STDIN/STDERR/just about any file descriptor *in the middle of* a
} script, not at the beginning?  That is,

You can do this in any Bourne-shell-like shell, even very old ones, with

exec <foo.in		# redirects stdin
exec >foo.out		# redirects stdout
exec 2>foo.err		# redirects stderr

This is all documented in the "Redirection" section of the zsh manual.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author