I have 1000+ *.tar.gz
files with size 4G+
each. But the only thing that I needed is the top 5 lines of each file. I am wondering whether there is a fast way to read these lines without uncompressing process (it takes 3-5 minutes to uncompress a single file).
My platform is Linux.
Asked
Active
Viewed 190 times
0
-
Possible duplicate of [is partial gz decompression possible?](http://stackoverflow.com/questions/23676116/is-partial-gz-decompression-possible) – 123 Jul 22 '16 at 13:18
-
I think you can use `split -b X` to take only the first X byes of the file, then decompress – Chris_Rands Jul 22 '16 at 13:24
1 Answers
1
No, there isn't any faster way.
The issue is that .tar
file is stream of concatenated original files (with some meta information). gzip
then adds compression of full archive. Therefore even to just get the list of the files the archive has to be uncompressed first.

Zbynek Vyskovsky - kvr000
- 18,186
- 3
- 35
- 43