Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-09-2008
Registered User
 

Join Date: Jul 2008
Posts: 4
Last 24 hours of a log file

I'm looking to pull the last 24 hours of a log file.

Here's what I've got so far:
yesterday=$(TZ=$TZ+24 date +"%b %e %H:%M")
today=$(date +"%b %e %H:%M")
echo $yesterday $today

grep -E "^$yesterday|^$today" /var/adm/syslog/syslog.log

But that pulls everything from $yesterday from 12:01am instead of 24 hrs prior to the current date and time.

Thoughts?

Thanks...
Sponsored Links
  #2 (permalink)  
Old 07-09-2008
Registered User
 

Join Date: Jun 2008
Posts: 98
Smile

Quote:
Originally Posted by Bert View Post
I'm looking to pull the last 24 hours of a log file.

Here's what I've got so far:
yesterday=$(TZ=$TZ+24 date +"%b %e %H:%M")
today=$(date +"%b %e %H:%M")
echo $yesterday $today

grep -E "^$yesterday|^$today" /var/adm/syslog/syslog.log

But that pulls everything from $yesterday from 12:01am instead of 24 hrs prior to the current date and time.

Thoughts?

Thanks...
Try this :
sed -n "/^${yesterday}/,/^${today}/ p" /var/adm/syslog/syslog.log
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
finding the file which is modified within last 2 hours trichyselva Shell Programming and Scripting 5 06-04-2009 02:53 PM
Searching for folders which are over 5 hours old. stevefox Shell Programming and Scripting 4 06-02-2008 12:13 AM
Have we just had a rollback of a few hours? porter Post Here to Contact Site Administrators and Moderators 1 12-17-2007 08:51 PM
list the file created before 24 hours using ls command jayaramanit Shell Programming and Scripting 7 09-11-2007 09:46 AM
delete files that are over 2 hours old hedrict UNIX for Dummies Questions & Answers 3 07-01-2002 01:06 PM



All times are GMT -4. The time now is 02:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0