Artificial intelligent assistant

How do I send output to both log file and console? I used to put this on top of all my scripts, with regards to the output. The stopping and starting of the docker works as expected, and the log files contain what it should but the console does not have output too. what did I miss here? #!/bin/sh LOGFILE="/mnt/user/HardHomeSystemData/SysLogs/PlexClear.log" exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>$LOGFILE 2>&1 #clear plexes codecs for EAC3 issues, stop the docker, rm codecs, restart docker docker stop plex rm -r /mnt/user/appdata/plex/Library/Application\ Support/Plex\ Media\ Server/Codecs/* docker start plex

I'm not sure howto to do it in `sh` but in bash you can do it with Process Substitution, and `tee` which should do what you wanted


#!/usr/bin/env bash

logfile=logfile.txt

exec 3>&1 4>&2

trap 'exec 2>&4 1>&3' 0 1 2 3

exec > >(tee -a "$logfile") 2>&1 ##: Print to stdout and logfile.


* See also Logging

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 87f92a7c871a745ba910392e47a1dfd3