Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Perl and zgrep

Posted on 2004-08-14
2
Medium Priority
?
683 Views
Last Modified: 2012-06-27
I have a small script that will search log files, the files go back several months, all the files that are over a week old are compressed so I use zgrep when seaching the ones older than a week. I have a small perl script that I use to search the files but cannot make it work on the files older than a week. Is there a way i can use zgrep in the script to search the zipped files.

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 20

Accepted Solution

by:
jmcg earned 2000 total points
ID: 11801048
Your script can call on zgrep or zcat to read the files or it can use the Compress::Zlib module to do the decompression itself.

open LOGF, "zcat $filename |" or die "failed starting zdat on $filename -- $!";

while( <LOGF> ) {
   # do your thing here -- use zgrep instead of zcat if the grep action does what you need
  }

0
 

Author Comment

by:bt707
ID: 11801102
Thanks for the info, i think i can get it going with that.

Thanks,
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

610 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