Solved

Perl and zgrep

Posted on 2004-08-14
2
627 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
2 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 500 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

823 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