Created
December 14, 2018 05:23
-
-
Save peterneave/374049cbfd8a87d9de3855fef363e6c6 to your computer and use it in GitHub Desktop.
Add datetime to log files
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
adddate() { | |
while IFS= read -r line; do | |
printf "%s %s\n" "[$(date +"%F %H:%M:%S")]" "$line" | |
done | |
} | |
$1 | adddate |
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
./logscript.sh ./somescript.sh >> yourlog_$(date +\%Y\%m\%d\%H\%M\%S).log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment