-
-
Save Jared-Prime/9963663 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Adds a timestamp beside every line of data received on STDIN. | |
# Turns this -> Into that: | |
# -> Time Data | |
# [INFO] event 1 -> 04-03-2014 12:00:01 [INFO] event 1 | |
# [INFO] event 2 -> 04-03-2014 12:00:02 [INFO] event 2 | |
# example usage: tail -f some.log | timestamp_it > some-timed.log | |
function timestamp_it { | |
echo -e "Time\tData" | |
while read line | |
do | |
date=$(date '+ %m-%d-%Y %H:%M:%S') | |
echo -e "$date\t$line" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment