Solved

perl print if and tabs

Posted on 2006-11-15
2
206 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

16 Experts available now in Live!

Get 1:1 Help Now