I have some code handed from someone long gone to another department. It purports to log everything to the $MBL location, however, it does not; it creates an empty file in the $MBL location :-(
exec > >(tee ${MBL}) 2>&1
I can tell 开发者_如何转开发that it takes stderr and sends it to stdout; I can tell that tee should output the result to stdout and to $MBL. However, I don't understand the exec > >()
syntax.
Reading the bash(1) man page suggests that a fork happens....
Two things going on here: exec
with only redirections redirects the shell's own file descriptors, and the >(command)
syntax in bash
and zsh
creates a pipe and substitutes a /dev/fd/*
reference to its input.
As written, this looks like it does what it is claimed to do.. but there may be other redirections in the script, or if it's being run in a shell that doesn't support >(command)
then it will spit out an error and do nothing useful.
精彩评论