I have a bash script where I'm using the following to direct the stdout/stderr of every command to a file:
today=`/bin/date '+%Y_%m_%d__%H_%M_%S'`
exec 2> "/home/pi/stream_logs/$today.$RANDOM.txt"
exec 1>&2
[command 1
command 2
command 3
command 4
.... (many more commands)]
I'd like to redirect the stdout/stderr of command 2 to a DIFFERENT file, while keeping the stdout/stderr of every other command going to /home/pi/stream_logs/$today.$RANDOM.txt.
How can I override & redirect JUST the output of one command in this script to a separate file?
command2happen beforecommand1?