LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 10-19-2010, 09:10 AM   #1
shivanrathore
Member
 
Registered: Apr 2008
Posts: 33

Rep: Reputation: 15
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
 
Old 10-19-2010, 10:12 AM   #2
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,692

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
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
 
Old 10-19-2010, 10:39 AM   #3
shivanrathore
Member
 
Registered: Apr 2008
Posts: 33

Original Poster
Rep: Reputation: 15
no ya .. time doesn't work .. it brings a output of old time as well
 
Old 10-19-2010, 10:52 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
 
  


Reply

Tags
egrep, grep, timestamp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux timestamp server questions pcsousa Linux - Server 5 11-19-2014 08:13 AM
sort oldest 5 files in a directory tree recursively based on timestamp Linux abhelp Programming 1 06-04-2010 05:58 AM
how do i activate IP timestamp in linux? iNET_boss Linux - Newbie 2 10-20-2005 09:10 AM
unix/linux timestamp sopiaz57 Linux - Security 3 06-16-2003 10:43 PM


All times are GMT -5. The time now is 12:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration