Solved

Perl and zgrep

Posted on 2004-08-14
2
601 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

19 Experts available now in Live!

Get 1:1 Help Now