LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Egrep on linux timestamp (http://www.linuxquestions.org/questions/linux-newbie-8/egrep-on-linux-timestamp-839040/)

shivanrathore 10-19-2010 08:10 AM

Egrep on linux timestamp
 
Hi

I want to egrep or a grep in the squid log file .. from this time 1287483952.440 to '1287483452.440 , how can i do it .Thanks

grail 10-19-2010 09:12 AM

Not sure about grep but you could do it with sed or awk pretty simply:
Code:

sed -n '/1287483952\.440/,/1287483452\.440/p' file

awk '/1287483952\.440/,/1287483452\.440/' file


shivanrathore 10-19-2010 09:39 AM

no ya .. time doesn't work .. it brings a output of old time as well

colucix 10-19-2010 09:52 AM

Maybe the log entries are not sorted? Anyway, you can easily extract lines whose time is between two specific timestamps using numeric comparison in awk:
Code:

awk '$1 >= 1287483452.440 && $1 <= 1287483952.440' squid.log


All times are GMT -5. The time now is 08:36 PM.