Reputation: 11
I want shell script output and error to be redirected to both file and console
I use #/bin/sh
and the following works in BASH but not in base shell (#/bin/sh
). Any ways to achieve this in #/bin/sh
?
set -x
exec > >(tee "logfile") 2>&1
And exec &> logfile will output only to file and not to standard output
Upvotes: 1
Views: 705
Reputation: 37288
/path/2/cmd 2>&1 | tee logfile
Is as old school as you can get.
IHTH
Upvotes: 2