Solved

Perl and zgrep

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl search and replace 6 173
Filtering a file to table 9 102
Having a problem with ActiveState Perl on 64-bit Windows 7 3 78
what are these modules in perl script 4 106
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…

730 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