I'm creating a script for users to run. I need to redirect the output to a file I'm creating from inside the script (hostname-date).
I have all the pieces except for how to copy the output of the script from inside the same script. All the examples I can find call the script and > it into the log, but this isn't an option.
-Alex
Add the following at the top of your script:
exec &> output.txt
It will make both stdin and stderr of the commands in the rest of your script go into the file output.txt
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With