How to use exec and tee to redirect logs to stdout and a log file in the same time

You probably need to run it in bash.
 
It does not work either if I run it through bash script:


honzhan@hz_BSD10:~/CodeTest/Shell % sh test1.sh
test1.sh: 2: Syntax error: redirection unexpected (expecting word)
honzhan@hz_BSD10:~/CodeTest/Shell % cat test1.sh
#!/bin/bash
exec &> >(tee -a log.txt)
 
Not your question, but in case you have to quickly unbashify something,
Code:
(
...lotsa commands...
) | tee log
does more or less the same

You'd expect exec | command would work like exec > file. Hmh...
Juha
 
Back
Top