Currently I have a script where I want all output to be redirected to both a file and the console.
#!/bin/bash
touch /mnt/ybdata/ybvwconf.log
{
... [Do some script code here]
} 2>&1 | tee -a /mnt/ybdata/ybvwconf.log
Above, you can see my current code, which works perfectly fine. It prints all the output to the console as well as piping it to the ybvwconf.log file. However, I was looking for a way to eliminate the curly brackets. Something along the lines of this:
#!/bin/bash
touch /mnt/ybdata/ybvwconf.log
exec 2>&1 | tee -a /mnt/ybdata/ybvwconf.log
... [Do some script code here]
I have tried this approach and sadly it does not work. I don't get any errors but no content appears in my log file. Any ideas what might be wrong?