LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to processing the log file within certain dates based on the file name (https://www.linuxquestions.org/questions/linux-general-1/how-to-processing-the-log-file-within-certain-dates-based-on-the-file-name-800830/)

shyork2001 04-08-2010 12:47 PM

How to processing the log file within certain dates based on the file name
 
Hi I am working on the script parsing specific message "TEST" from multiple file. The log file name looks like:

N3.2009-11-26-03-05-02.console.log.tar.gz
N4.2009-11-29-00-25-03.console.log.tar.gz
N6.2009-12-01-10-05-02.console.log.tar.gz

I am using the following command:

zgrep -a --text "TEST" * | awk -F"[ .,]" '{sub(".*:","",$6); sub(",.*","",$7); print $1,$6,$7,$10}

and getting
N3 2009-11-25 20:12:57 TEST
N4 2009-11-28 10:42:18 TEST
N6 2009-12-01 10:00:24 TEST

If I only want to search the log file after 2009-11-29, what shall I change the command?


Thanks

whizje 04-08-2010 03:35 PM

You can use the mktime function in awk seehttp://www.delorie.com/gnu/docs/gawk/gawk_138.html


All times are GMT -5. The time now is 04:05 PM.