![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep question. | saurabhsinha23 | UNIX for Dummies Questions & Answers | 3 | 12-11-2007 01:58 AM |
| Question about GREP | Adriel | UNIX for Dummies Questions & Answers | 16 | 03-22-2007 08:03 AM |
| Another grep question | kingdbag | UNIX for Dummies Questions & Answers | 6 | 10-27-2006 02:56 AM |
| grep & sed question | der Kopf | Shell Programming and Scripting | 1 | 11-22-2004 04:49 AM |
| Grep question | eloquent99 | UNIX for Dummies Questions & Answers | 4 | 02-20-2003 10:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Grep question
I have a large log file. I want to keep 1 week worth of records. This is what part of file looks like:
Oct 04 09:16:59 [INFORMATION] Order intfc ended normally on 10/04/2004 at 09:16. Oct 04 09:16:59 [INFORMATION] ------------------------------------------------ Oct 04 09:16:59 [INFORMATION] TM: Program <Iordload> ended (normal, exit <0>). ******** WARNING: The following errors occurred running sqlldr... SQL*Loader: Release 9.2.0.5.0 - Production on Mon Oct 4 09:16:57 2004 Oct 04 09:32:04 [INFORMATION] Access code is valid. Oct 04 09:32:04 [INFORMATION] Task master: Program <Iordload> started. Oct 04 09:32:04 [WARNING] Ord <B394588-SFI>: cannot modify ord that does not exist. Ord will be added with <I> status. Is there a way to truncate the records that are less than today's date - 7 days? I think it would be easier to do if each and every record began with a date, but in this file they don't. Any help would be greatly appreciated. |
|
|||||
|
On second thoughts!!
If you want lines in the log which have the date exactly 1 week from todays date you can try: code: Quote:
enc. |
|
||||
|
This log file gets auto generated by another system of ours. I was just trying to point out that in this file, not all of the lines have a timestamp associated with them. Maybe it would be easier and better if I could just figure out how to chop off the first X rows from the file.
|
|
|||||
|
U can write the log file every day to a new different file based on date format ;
If u do n't have a control of this ......, Is there any pattern of 'first line' it prints on every day ; Find out the line number using 'grep' ; Let's say that is 'm' Try for the second day using grep ; Let's say the second day starts with line number 'n' Seperate the first day logs using head and tail .... between m and n-1 lines. Repeast the same thing for other 6 days. Hope this helps. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|