Created
October 28, 2021 03:40
-
-
Save dathanb/fccc74fc15834129e9ae4f841826c88a to your computer and use it in GitHub Desktop.
Redirect stdout and stderr from within a script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logFile=~/log | |
# close stdout and stderr and redirect them to the log file | |
rm -f "${logFile}" | |
exec 1<&- | |
exec 2<&- | |
exec 1<>"${logFile}" | |
exec 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment