Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: dynamic zcat and grep

by eff_i_g (Curate)
on Mar 21, 2006 at 23:10 UTC ( #538338=note: print w/ replies, xml ) Need Help??

in reply to dynamic zcat and grep

What Unix and Perl are you running? Just curious.

I was able to get this to work in two ways:

  1. I can only use zcat on .Z files, therefore, I used gunzip -c.
  2. I created a .Z file via compress and used zcat as you have.

Does zcat -h give you any further information?

Comment on Re: dynamic zcat and grep
Re^2: dynamic zcat and grep
by clmcshque (Initiate) on Mar 21, 2006 at 23:50 UTC
    Thanks for the reply. I'm using - perl, v5.8.7 built for i686-linux Red Hat Enterprise zcat works for me when I enter it via the command line, not when it is in a perl script. gunzip -c gives the same errors. When I use single quotes:
    gunzip: compressed data not read from a terminal. Use -f to force deco +mpression. For help, type: gunzip -h
    When I use double quotes:
    ERROR - Could not open log.gz

      Since you are on a Red Hat machine anyway, you can save yourself a lot of time just by using 'zgrep'.

      We're not surrounded, we're in a target-rich environment!
        Thanks for the reply. zgrep works great on the command line, but how do I get it to work within my script? Could I do the following: (I would try it but don't have access to the system right now)
        $grep = /something/; $gzfile = file.gz; open OUTPUT "zgrep $grep $gzfile |";
      You may be able to get a better idea of what is going wrong if you include $! in your error message. This is the variable in which Perl stores the O/S error message when things like open fail, e.g.

      $fn = "non_existant_file"; open IN, "<$fn" or die "open: $fn: $!\n";

      would error with

      open: non_existant_file: no such file or directory



Re^2: dynamic zcat and grep
by thor (Priest) on Mar 22, 2006 at 00:33 UTC
    On some systems, gunzip -c and zcat are identical.
    thulben@alpha:~ 17 $ md5sum /bin/gzip /bin/zcat /bin/gunzip 57cd8cdf42fbda6e0a1f5e17ac986b4f /bin/gzip 57cd8cdf42fbda6e0a1f5e17ac986b4f /bin/zcat 57cd8cdf42fbda6e0a1f5e17ac986b4f /bin/gunzip
    The executable is one of those "magic" ones that recognizes how it was called and alters its behavior appropriately.


    The only easy day was yesterday

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://538338]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-05-24 09:58 GMT
Find Nodes?
    Voting Booth?

    In my home, the TV remote control is ...

    Results (472 votes), past polls