を取得しfilesizeの非常に大きい。gzファイル64bitプ
質問
よspecifictionのgzのfilesizeが保存された最後の4bytesの。gzファイルです。
私が作成した2つのファイル
dd if=/dev/urandom of=500M bs=1024 count=500000
dd if=/dev/urandom of=5G bs=1024 count=5000000
I gzipedし
gzip 500M 5G
を確認しましたが最後の4バイトをやってい
tail -c4 500M|od -I (returns 512000000 as expected)
tail -c4 5G|od -I (returns 825032704 as not expected)
この打ち目に見えない32ビットのバリアに書き込まれる値のISIZE全く意味がない。ると面倒によれば利用した一部のエラービットです。
なんだろうけど、日本人のわかりやすく伝えるための圧縮解除された.gz filesizeするために設計されています。gzなく抽出しですか?
感謝
仕様: http://www.gzip.org/zlib/rfc-gzip.html
編集:が誰にでもしたりすることができますが/dev/zeroの代わりに/dev/urandom
解決
1がありません。
圧縮ストリームの正確なサイズを取得する唯一の方法は、(あなたがを/ dev / nullにすべてを書き込み、ちょうどバイトを数えても)実際に行くと解凍することです。
ISIZEは次のように定義されていることは注目に値する。その
ISIZE(入力サイズ)
これは、元の(非圧縮)入力
のサイズが含まれています データは、2 ^ 32を法
gzipの RFC の中には、の<速報/全角、実際にはないので、 > 32ビットのバリアで、何をしているシーイングが予想される動作です。
他のヒント
まだ試したことのファイルのサイズですが、私の された、圧縮解除された サイズ。gzファイル
zcat file.gz | wc -c
時にならないようにしたい出された、圧縮解除されたファイル添い寝、または迷惑を圧縮を設定することができます。
当然のことながら、データの圧縮解除されたものの、そのパ wc
.
で、試してみます。
編集: もし作成5Gファイルからデータを/dev/ランダムでファイル 5G
サイズ5120000000が、私とファイルマネージャー報告として4.8G
そして圧縮し gzip 5G
, の結果 5G.gz
同じサイズなの圧縮 ランダム のとします。
その zcat 5G.gz | wc -c
の報告と同じサイズのオリジナルファイル:5120000000バイトまでとなります。これだけいった試行されています。
コ待ち
gzipの-lオプションを持っています:
-l --list
For each compressed file, list the following fields:
compressed size: size of the compressed file
uncompressed size: size of the uncompressed file
ratio: compression ratio (0.0% if unknown)
uncompressed_name: name of the uncompressed file
The uncompressed size is given as -1 for files not in gzip format, such as compressed .Z files. To
get the uncompressed size for such a file, you can use:
zcat file.Z | wc -c
In combination with the --verbose option, the following fields are also displayed:
method: compression method
crc: the 32-bit CRC of the uncompressed data
date & time: time stamp for the uncompressed file
The compression methods currently supported are deflate, compress, lzh (SCO compress -H) and pack.
The crc is given as ffffffff for a file not in gzip format.
With --name, the uncompressed name, date and time are those stored within the compress file if
present.
With --verbose, the size totals and compression ratio for all files is also displayed, unless some
sizes are unknown. With --quiet, the title and totals lines are not displayed.