#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    141
    Rep Power
    15

    Possible to Grep within .gz file without uncompress first?


    When uncompressed the file size is over 800 megs, I wanted to know if I can search for a string within the compressed .gz file without uncompressing...
  2. #2
  3. Trapped on the forums...help
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2003
    Location
    /Users/edman007
    Posts
    4,602
    Rep Power
    909
    well your going to have to decompress it in one way, but you don't have to store the uncompressed data

    Code:
    zcat /file.gz | grep string
    that will decompress it and pipe it to grep, so it will take a lot of CPU, but its won't store anything to the hard drive
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    141
    Rep Power
    15
    Originally Posted by edman007
    well your going to have to decompress it in one way, but you don't have to store the uncompressed data

    Code:
    zcat /file.gz | grep string
    that will decompress it and pipe it to grep, so it will take a lot of CPU, but its won't store anything to the hard drive
    Thanks I'll give that a shot.
  6. #4
  7. No Profile Picture
    ......@.........
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2004
    Posts
    1,345
    Rep Power
    59
    Consider also:
    Code:
    zgrep 'value to find' filename.gz

    Comments on this post

    • kicken agrees

IMN logo majestic logo threadwatch logo seochat tools logo