Solved

perl print if and tabs

Posted on 2006-11-15
2
207 Views
Last Modified: 2008-02-26
I need to print out a couple of parts of a certain line.

I need to fine all lines that contian "YSanchez4" and "summary=" from lines such as this one

[15/Nov/2006:22:10:34 +0000] usxsl069 cshttpd[14839]: General Notice: (SSL) : POST: /storeevents.wcap?id=5ph5rn0o0p0e5qm0&calid=YSanchez4&dtstart=20020101T120000&dtend=20020101T010000&summary=New Year's Day&desc=&location=United States&icsClass=PUBLIC&isAllDay=1&categories=Holiday&charset=UTF-8&fmt-out=text/xml


I need to print out the summary= and the start and end time.

From this line I would get a print out of:

summary=New Year's Day      20020101T120000      20020101T010000

I'm getting the summary=... but when I try to add a few tabs and the start and end times I'm just getting a blank output,
can't figure out what I'm doing wrong here.

This is giving me the 1st part of what I need, need some help to get the start and end times.

perl -ne 'print "$1\n" if /(summary=.*)&desc=/'


Thanks,
0
Comment
Question by:bt707
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17951616
If dtstart, dtend, summary, and desc are always in the same order
perl -ne 'print "$3\t$1\t$2\n" if /dtstart=(.*?)&.*dtend=(.*?)&(summary=.*)&desc=/'
0
 

Author Comment

by:bt707
ID: 17951652
Thanks ozo, that's just what I was trying to do, I just added a "/YSanchez4/ &" to it and got just what I needed.

Thanks again!!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now