shell - cannot understand combined exec and redirection in bash script -
i know exec executing program in current process quoted down here
exec replaces current program in current process, without forking new process. not use in every script write, comes in handy on occasion.
i'm looking @ bash script line of can't understand exactly.
#!/bin/bash log="log.txt" exec &> >(tee -a "$log") echo logging output "$log"
here, exec doesn't have program name run. mean? , seems capturing execution output log file. understand if exec program |& tee log.txt
here, cannot understand exec &> >(tee -a log.txt)
. why >
after &>
?
what's meaning of line? (i know -a option appending , &>
redirecting including stderr)
edit : after selected solution, found exec &> >(tee -a "$log")
works when bash shell(not sh). modified initial #!/bin/sh
#!/bin/bash
. exec &>> "$log"
works both bash , sh.
from man bash
:
exec [-cl] [-a name] [command [arguments]]
if command not specified, redirections take effect in current shell, [...]
and rest:
&> # redirects stdout , stderr >(cmd) # redirects process
see process substitution.
Comments
Post a Comment