الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

bzip2, bunzip2, bzcat

Compress files to .bz2 (bzip2), unpack them (bunzip2), or read them without unpacking (bzcat).

المستوى
امتحان RHCSA
المجموعة
الأرشفة والضغط
يحتاج root
لا
الحزمة
bzip2
يُسمّى أيضًا
bunzip2, bzcat, bzgrep

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

bzip2 makes smaller files than gzip, but it is slower. It replaces FILE with FILE.bz2. The RHCSA objectives name bzip2 together with tar and gzip.

Like gzip, it works on single files. For folders, use tar -cjf (the -j option calls bzip2).

Read .bz2 files without unpacking with bzcat, bzless, bzgrep.

طريقة الكتابة

bzip2 [OPTIONS] [FILE...]
bunzip2 [OPTIONS] [FILE...]
bzcat [-s] [FILE...]

الخيارات 14

الأكثر استخدامًا

-d, --decompress
Decompress (same as bunzip2).
-z, --compress
Compress (the default for bzip2).
-k, --keep
Keep the original file.
-c, --stdout
Write to the screen (stdout), keep the files.
-t, --test
Test the file: is it complete and not damaged?
-f, --force
Overwrite existing output files.
-q, --quiet
Hide warnings that are not important.
-v, --verbose
Show the ratio of each file (-vv for more).
-s, --small
Use less memory (slower), for small machines.
-1 ... -9
Block size 100k to 900k. -9 (the default) compresses best.
--fast
Same as -1.
--best
Same as -9.
-L, --license, -V, --version
Show the license and version.
-h, --help
Show help.

أمثلة 12

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Compress a file

    bzip2 report.csv

    You get report.csv.bz2; the original is removed.

  2. 2Decompress

    bunzip2 report.csv.bz2

    Same as bzip2 -d report.csv.bz2.

  3. 3Keep the original

    bzip2 -k big.log

    Both files stay.

  4. 4Make a tar archive with bzip2

    tar -cjf etc.tar.bz2 /etc

    The -j option uses bzip2.

  5. 5Extract a tar.bz2 archive

    tar -xjf etc.tar.bz2 -C /tmp

    Plain -xf also works; tar detects bzip2.

  6. 6Read without unpacking

    bzcat data.txt.bz2 | head

    Fast look at the first lines.

  7. 7Search inside .bz2 files

    bzgrep "ERROR" app-*.log.bz2

    Like grep, but on compressed files.

  8. 8Test a file

    bzip2 -tv backup.sql.bz2

    Shows "ok" when the file is good.

  9. 9Compare sizes of gzip, bzip2 and xz

    for c in gzip bzip2 xz; do $c -c big.log > big.$c; done; ls -lh big.*

    See which one fits your data best.

  10. 10Compress a stream

    mysqldump shop | bzip2 > shop.sql.bz2

    No uncompressed copy on disk.

  11. 11Decompress to stdout and keep the archive

    bzip2 -dc logs.tar.bz2 | tar -t

    List the tar content without writing anything.

  12. 12Use less memory on a small VM

    bzip2 -s huge.dump

    Slower, but it fits in little RAM.

انتبه

  • bzip2 removes the original by default. Use -k to keep it.
  • bzip2 is slow for big data. For speed use gzip (or pigz); for the smallest size use xz.

نصائح للحفظ

  • bzip2 / bunzip2 / bzcat. In tar: -j.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man bzip2