LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 08: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, 09:12 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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, 09: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, 09:52 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

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



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 07:13 AM
sort oldest 5 files in a directory tree recursively based on timestamp Linux abhelp Programming 1 06-04-2010 04:58 AM
how do i activate IP timestamp in linux? iNET_boss Linux - Newbie 2 10-20-2005 08:10 AM
unix/linux timestamp sopiaz57 Linux - Security 3 06-16-2003 09:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:21 PM.

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
Open Source Consulting | Domain Registration