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 ...
- 12-18-2008 #1Just 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.
- 12-18-2008 #2There is no magic bullet.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.
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.
- 12-18-2008 #3
Don't know but have you played with "tac" command


Reply With Quote