Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I want to implement the following functionallity: gzcat | tail. The main objective is say...say you have huge files of size 3 or 5GB in the format *.gz. You ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    1

    tail implementation of zipped files

    Hi,

    I want to implement the following functionallity:

    gzcat | tail.

    The main objective is say...say you have huge files of size 3 or 5GB in the format *.gz. You just want to see the last few lines of this file.

    I really do not have a clue how to get to the last of a stream. Java has this GZipInputStream class which returns the unzipped stream. But I could find no clue how to get to the end of the stream and then run backwards. I cannot use RandomAccessFile as then you need to take that huge .gz file and extract.

    If I can implement it in some other language even that will help.

    Can anyone help?

    Thanks,
    Ananya.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    You just want to see the last few lines of this file.

    I really do not have a clue how to get to the last of a stream. Java has this GZipInputStream class which returns the unzipped stream. But I could find no clue how to get to the end of the stream and then run backwards.
    There is no magic bullet.

    If you want to see, say, the final five lines of a stream, you read the stream, saving the content of the most recent five lines as you go. First you save the first five; then you read a new line and throw away the first line; then you read another new line and throw away the second line; and so on.

    The best you can hope for is to find some class that will do this automatically for you. I have never seen any compression algorithm, whether used by gzip or not, which was designed so you could "run backwards" from the end. They're all pretty much sequential, running from the beginning.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Linux Newbie Sangal-Arun's Avatar
    Join Date
    May 2006
    Location
    Gurgaon, India + Denver Colorado USA
    Posts
    101
    Don't know but have you played with "tac" command
    Brgds,

    ARUN SANGAL
    SCM: 1- 720 251 9962
    Email: sangal.ak04@gmail.com
    Email: sangal_ak04@yahoo.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...