Solved

perl print if and tabs

Posted on 2006-11-15
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

695 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