Solved

perl print if and tabs

Posted on 2006-11-15
2
208 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to delete rows in a file based on the file name. 5 60
rename outfile before writing 2 72
Perl string replace for refred url 9 62
Call Shell Script from Perl Script 6 97
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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