Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
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.
Zo schrijf je het
bzip2 [OPTIONS] [FILE...]
bunzip2 [OPTIONS] [FILE...]
bzcat [-s] [FILE...]Opties 14
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 12
$ als gewone gebruiker# als root (of met sudo)
1Compress a file
bzip2 report.csvYou get report.csv.bz2; the original is removed.
2Decompress
bunzip2 report.csv.bz2Same as
bzip2 -d report.csv.bz2.3Keep the original
bzip2 -k big.logBoth files stay.
4Make a tar archive with bzip2
tar -cjf etc.tar.bz2 /etcThe
-joption uses bzip2.5Extract a tar.bz2 archive
tar -xjf etc.tar.bz2 -C /tmpPlain
-xfalso works; tar detects bzip2.6Read without unpacking
bzcat data.txt.bz2 | headFast look at the first lines.
7Search inside .bz2 files
bzgrep "ERROR" app-*.log.bz2Like grep, but on compressed files.
8Test a file
bzip2 -tv backup.sql.bz2Shows "ok" when the file is good.
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.
10Compress a stream
mysqldump shop | bzip2 > shop.sql.bz2No uncompressed copy on disk.
11Decompress to stdout and keep the archive
bzip2 -dc logs.tar.bz2 | tar -tList the tar content without writing anything.
12Use less memory on a small VM
bzip2 -s huge.dumpSlower, but it fits in little RAM.
Niets past bij dit filter.
Let op
- bzip2 removes the original by default. Use
-kto keep it. - bzip2 is slow for big data. For speed use gzip (or pigz); for the smallest size use xz.
Tips om te onthouden
- bzip2 / bunzip2 / bzcat. In tar:
-j.