I have found some info on this, but not enough to get me going with this project. I have limited bash experience, trying to learn.
I have a log file that I would like to read (tail) and process lines as they come in based on timestamp in the log.
Log example: from a tail -f filename.txt | grep --line-buffered RXKEY,MAIN:
20230913200618,12345,RXKEY,MAIN
20230913200620,12345,RXKEY,MAIN
20230913200627,12345,RXKEY,MAIN
20230913200629,12345,RXKEY,MAIN
(Timestamp,id,type,location)
I would like to read this file and perform an action, if the last entry was X amount of seconds before the previous entry. IE, if 2 logs hit in 4 or 5 seconds apart, run a command locally. Then keep monitoring for future logs and repeat as needed.
I have the log working but not sure how to read the timestamps and then process an action.
You can pipe
grepintowhile read, which lets you loop over each line received.Tried to comment more than usual as you said you're new to
bashbut let me know if something isn't understandable.