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 > UNIX for Dummies Questions & Answers
.
google unix.com



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
awk and regular expression maskot Shell Programming and Scripting 4 05-22-2007 08:22 AM
Regular Expression problem djkane Shell Programming and Scripting 5 06-21-2006 11:07 AM
Regular Expression Problem netmaster UNIX for Dummies Questions & Answers 1 12-07-2005 09:34 PM
Complex Pipeline/Redirection/Regular Expression problem netmaster UNIX for Dummies Questions & Answers 1 11-29-2005 12:55 AM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 11:59 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-01-2008
chris1234 chris1234 is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 74
Regular Expression Problem

this is how my xyz.log file loooks like :-

[30/Dec/2008:12:03:07] info ( 816): CORE1116: Sun ONE Web Server 6.1SP5 B08/17/2005 22:09
[31/Dec/2008:12:03:08] info ( 817): CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.5.0_11] from [Sun Microsystems Inc
.]
[01/Jan/2008:12:03:08] info ( 817): WEB0100: Loading web module in virtual server [http-google] at [/abc]
[02/Jan/2008:12:03:08] info ( 817): WEB0100: Loading web module in virtual server [http-google] at [/abc]


Code:
perl -MPOSIX -i.bak  -ne 'BEGIN{

 $d=strftime("%d%m%Y",localtime time-60*24*60*60);
 @m{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)}=("01".."12")}

 print if m"^(\d+)/(\w+)/(\d{4})"&& "$1$m{$2}$3" gt $d' xyz.log
I am trying to keep the last 60 days data and delete everything else but for some reason its deleting everything in xyz.log instead of keeping the last 60 days and deleting the rest.

Any info will be really appreciated. I am new to regular expression.
 

Bookmarks

Tags
perl, perl regex, regex, regular expressions

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

Content Relevant URLs by vBSEO 3.2.0