[Solved] Read a .gz file line by line without using gzcat

Hi all
Is there a way to read and process a gzip file line by line similar to a text file without using gzcat..

while processing a text file we will usually use the logic

exec<sample.txt
while read line
do 
echo $line
done

Is there a similar way to process the gz file in the same manner line by line without using gzcat .Thanks all in advance

why you don't want to use gzcat?
another option would be then gunzip->process->gzip

gzcat does 2 things : gunzip on the fly, and cat of content, all that to STD OUT.
This allows you to

gzcat my_tar_archive.tgz | tar -tvf -

If you are to not use gzcat ( could be you havent got it installed...), as the previous post suggest, you are to use gunzip and uncompress, read content and create the .gz file again

Since gzip, gunzip and gzcat are the same executable, so if you have one, you have all, available all over as a binary or source. Normally, you do something like this:

gunzip < file.gz | while read ln
do
. . .
done

Compatability: uncompress will not work on .gz, but gunzip, gzcat work on compress output (.Z).

Tell us more.

Thanks Guys For ur Replies..
the problem i had was gzcat was not installed in my system and was not able to figure out the solution for a line by line processing . your posts solved my problem :):slight_smile: