![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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
}
|
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|