You can use gzip -cd file.gz | dd ibs=1024 count=10
to uncompress just the first 10 KiB, for example.
gzip -cd
decompresses to the standard output.
Pipe |
this into the dd
utility.
The dd
utility copies the standard input to the standard output.
Sodd ibs=1024
sets the input block size to 1024 bytes instead of the default 512.
And count=10
Copies only 10 input blocks, thus halting the gzip decompression.
You'll want to do gzip -cd file.gz | dd count=1
using the standard 512 block size and just ignore the extra 12 bytes.
A comment highlights that you can use gzip -cd file.gz | head -c $((1024*10))
or in this specific case gzip -cd file.gz | head -c $(512)
. The comment that the original dd
relies on gzip decompressing in 1024 doesn't seem to true. For example dd ibs=2 count=10
decompresses the first 20 bytes.