I have some log files. I've been asked to grep out error messages that have happened ONLY today. (However, the logs keep messages a long time so they have error messages going back weeks)
They log details in these fields (order):
Month Day Time Server message
I can grep out the month and day. However, on some of the log files....there is 1 space between Month and Day, and on other log files there is 2 spaces.
SO my grep works with the 1 space, but not the 2 space log files.
this is my command:
cat file_name | cut -d " " -f 1,2
how do i get it to grep out the dates even with 2 spaces between the Month and Time?
Also, i would then like to email out if the date matches today's date....and if not, email out that nothing has changed or been logged today.
Please do not leave people guessing. Show a representative sample of input, desired output, attempts at a solution and specify what OS and versions being used, or this thread will be closed.
May 19 20:34:33 server_name Process: Error_message_timed_out
I can grep out the month and day. However, on some of the log files....there is 1 space between Month and Day, and on other log files there is 2 spaces.
SO my grep works with the 1 space, but not the 2 space log files.
this is my command:
cat file_name | cut -d " " -f 1,2
tho i'm guessing (after getting my award) that it should be
<file_name | cut -d " " -f 1,2
how do i get it to grep out the dates even with 2 spaces between the Month and Time?
Also, i would then like to email out if the date matches today's date....and if not, email out that nothing has changed or been logged today.
Please also post sample data for a day of the month with a single-digit day.
Also sample data for every possible variation in the date field of the input record format.