I have a zipped text file a.zip I want to read the first 10 lines of it. Is it possible to do that without unzipping the whole file?
Asked
Active
Viewed 9,695 times
7
yukashima huksay
- 1,057
1 Answers
11
This simple pipe-script works for me:
zcat a.zip | head -n 10
Here:
zcat a.zip- unpacks zip-archive and sends its contents to standard output|pipeszcatoutput toheadinputhead -n 10- shows first 10 lines from its standard input
N0rbert
- 103,523
a.zip. Whenheadterminates (after printing 10 lines) thezcat(which isgzip -dcbehind the scenes) should receive a SIGPIPE and stop unzipping. – PerlDuck Jan 04 '18 at 11:53zcat verybigfile.zip | head -10prints the first 10 lines immediately. A full unzip would take ca. 10 minutes. – cubic lettuce Aug 21 '20 at 14:55