The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find log file between two dates justin_mca Shell Programming and Scripting 1 04-14-2008 10:32 AM
Help to switch dates from a file osramos Shell Programming and Scripting 2 11-15-2007 02:24 AM
grep a log file between 2 dates Epiphone Shell Programming and Scripting 37 07-31-2007 04:20 PM
Searching between dates Khoomfire Shell Programming and Scripting 9 08-22-2005 11:11 AM
Formatting dates in a file maverick UNIX for Dummies Questions & Answers 6 12-18-2001 11:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-22-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
help searching log file with dates

Im tyring to create a script that will show me any lines in a file with todays date and yesterdays, the date format in the file is as follows



----- amqxfdcx.c : 728 --------------------------------------------------------
07/12/05 09:53:20
AMQ6109: An internal WebSphere MQ error has occurred.

EXPLANATION:
An error has been detected, and the WebSphere MQ error recording routine has bee
n
called.
ACTION:
Use the standard facilities supplied with your system to record the problem
identifier, and to save the generated output files. Contact your IBM support
center. Do not discard these files until the problem has been resolved.

It would be nice if I could capture the whole message, not sure if that is possible, but at least if the script could print out any times todays date and yesterdays is in written in the log
  #2 (permalink)  
Old 08-23-2005
futurelet futurelet is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 137
This Ruby program will do it:
Code:
today = Time.now.strftime('%m/%d/%y')
yesterday = (Time.now - 24*60*60).strftime('%m/%d/%y')

array=ARGF.read.split(%r!(^\d+/\d+/\d+)!)

(1..array.size).step(2){ |i|
  if (array[i] == today) or (array[i] == yesterday)
    print array[i] + array[i+1]
  end
}
  #3 (permalink)  
Old 08-23-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
Quote:
Originally Posted by futurelet
This Ruby program will do it:
Code:
today = Time.now.strftime('%m/%d/%y')
yesterday = (Time.now - 24*60*60).strftime('%m/%d/%y')

array=ARGF.read.split(%r!(^\d+/\d+/\d+)!)

(1..array.size).step(2){ |i|
  if (array[i] == today) or (array[i] == yesterday)
    print array[i] + array[i+1]
  end
}
what shell is this written in?
  #4 (permalink)  
Old 08-23-2005
futurelet futurelet is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 137
It's written in the Ruby programming language. Think of it as a much more powerful replacement for Awk. I'd recommend installing it if you don't already have it.
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 On




All times are GMT -4. The time now is 01:49 PM.


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-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0