احصل على ملفات ملف .GZ كبيرة جدًا على منصة 64 بت
سؤال
وفقًا لمحددة GZ ، يتم حفظ ملفات الملفات في آخر 4Bytes من ملف .gz.
لقد قمت بإنشاء ملفين مع
dd if=/dev/urandom of=500M bs=1024 count=500000
dd if=/dev/urandom of=5G bs=1024 count=5000000
أنا gziped لهم
gzip 500M 5G
راجعت آخر 4 بايتات
tail -c4 500M|od -I (returns 512000000 as expected)
tail -c4 5G|od -I (returns 825032704 as not expected)
يبدو أن ضرب حاجز 32bit غير المرئي ، يجعل القيمة المكتوبة في هراء isize تماما. وهو أمر مزعج أكثر ، مما لو كانوا قد استخدموا بعض الخطأ بدلاً من ذلك.
هل يعرف أي شخص طريقة للحصول على ملفات .GZ غير مضغوطة من .GZ دون استخراجها؟
شكرًا
تخصيص: http://www.gzip.org/zlib/rfc-gzip.html
تحرير: إذا كان أي شخص يجربه ، فيمكنك استخدام /dev /Zero بدلاً من /dev /urandom
المحلول
لا يوجد واحد.
الطريقة الوحيدة للحصول على الحجم الدقيق للتيار المضغوط هي الذهاب فعليًا وإزالة ضغطه (حتى لو كتبت كل شيء على /dev /null وحساب البايتات).
تجدر الإشارة إلى أن isize يتم تعريفها على أنها
isize (حجم الإدخال)
هذا يحتوي على حجم الإدخال الأصلي (غير المضغوط)
بيانات Modulo 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.