{
    "content": [
        {
            "type": "text",
            "text": "# bzip2 (info)\n\n## NAME\n\nbzip2, bunzip2 - a block-sorting file compressor, v1.0.8 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files\n\n## SYNOPSIS\n\nbzip2 [ -cdfkqstvzVL123456789 ] [ filenames ...  ]\nbzip2 [ -h|--help ]\nbunzip2 [ -fkvsVL ] [ filenames ...  ]\nbunzip2 [ -h|--help ]\nbzcat [ -s ] [ filenames ...  ]\nbzcat [ -h|--help ]\nbzip2recover filename\n\n## DESCRIPTION\n\nbzip2  compresses  files  using  the Burrows-Wheeler block sorting text\ncompression algorithm, and Huffman coding.   Compression  is  generally\nconsiderably   better   than   that   achieved   by  more  conventional\nLZ77/LZ78-based compressors, and approaches the performance of the  PPM\nfamily of statistical compressors.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS**\n- **MEMORY MANAGEMENT**\n- **RECOVERING DATA FROM DAMAGED FILES**\n- **PERFORMANCE NOTES**\n- **CAVEATS**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "bzip2",
        "section": "",
        "mode": "info",
        "summary": "bzip2, bunzip2 - a block-sorting file compressor, v1.0.8 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files",
        "synopsis": "bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ...  ]\nbzip2 [ -h|--help ]\nbunzip2 [ -fkvsVL ] [ filenames ...  ]\nbunzip2 [ -h|--help ]\nbzcat [ -s ] [ filenames ...  ]\nbzcat [ -h|--help ]\nbzip2recover filename",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 90,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 79,
                "subsections": []
            },
            {
                "name": "MEMORY MANAGEMENT",
                "lines": 64,
                "subsections": []
            },
            {
                "name": "RECOVERING DATA FROM DAMAGED FILES",
                "lines": 28,
                "subsections": []
            },
            {
                "name": "PERFORMANCE NOTES",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 20,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "bzip2, bunzip2 - a block-sorting file compressor, v1.0.8\nbzcat - decompresses files to stdout\nbzip2recover - recovers data from damaged bzip2 files\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ...  ]\nbzip2 [ -h|--help ]\nbunzip2 [ -fkvsVL ] [ filenames ...  ]\nbunzip2 [ -h|--help ]\nbzcat [ -s ] [ filenames ...  ]\nbzcat [ -h|--help ]\nbzip2recover filename\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "bzip2  compresses  files  using  the Burrows-Wheeler block sorting text\ncompression algorithm, and Huffman coding.   Compression  is  generally\nconsiderably   better   than   that   achieved   by  more  conventional\nLZ77/LZ78-based compressors, and approaches the performance of the  PPM\nfamily of statistical compressors.\n\nThe  command-line options are deliberately very similar to those of GNU\ngzip, but they are not identical.\n\nbzip2 expects a list of file names to accompany the command-line flags.\nEach  file is replaced by a compressed version of itself, with the name\n\"originalname.bz2\".  Each compressed file has  the  same  modification\ndate,  permissions,  and, when possible, ownership as the corresponding\noriginal, so that these properties can be correctly restored at  decom-\npression  time.  File name handling is naive in the sense that there is\nno mechanism for preserving original file  names,  permissions,  owner-\nships  or dates in filesystems which lack these concepts, or have seri-\nous file name length restrictions, such as MS-DOS.\n\nbzip2 and bunzip2 will by default not overwrite existing files.  If you\nwant this to happen, specify the -f flag.\n\nIf no file names are specified, bzip2 compresses from standard input to\nstandard output.  In this case, bzip2 will decline to write  compressed\noutput  to  a  terminal, as this would be entirely incomprehensible and\ntherefore pointless.\n\nbunzip2 (or bzip2 -d) decompresses all specified  files.   Files  which\nwere  not  created by bzip2 will be detected and ignored, and a warning\nissued.  bzip2 attempts to guess the filename for the decompressed file\nfrom that of the compressed file as follows:\n\nfilename.bz2    becomes   filename\nfilename.bz     becomes   filename\nfilename.tbz2   becomes   filename.tar\nfilename.tbz    becomes   filename.tar\nanyothername    becomes   anyothername.out\n\nIf  the  file does not end in one of the recognised endings, .bz2, .bz,\n.tbz2 or .tbz, bzip2 complains that it cannot guess  the  name  of  the\noriginal file, and uses the original name with .out appended.\n\nAs  with  compression, supplying no filenames causes decompression from\nstandard input to standard output.\n\nbunzip2 will correctly decompress a file which is the concatenation  of\ntwo  or  more compressed files.  The result is the concatenation of the\ncorresponding uncompressed files.  Integrity testing (-t)  of  concate-\nnated compressed files is also supported.\n\nYou  can  also  compress  or decompress files to the standard output by\ngiving the -c flag.  Multiple files may be compressed and  decompressed\nlike this.  The resulting outputs are fed sequentially to stdout.  Com-\npression of multiple files in this manner generates a stream containing\nmultiple  compressed file representations.  Such a stream can be decom-\npressed correctly only by bzip2 version 0.9.0 or later.   Earlier  ver-\nsions  of  bzip2  will  stop  after decompressing the first file in the\nstream.\n\nbzcat (or bzip2 -dc) decompresses all specified files to  the  standard\noutput.\n\nbzip2  will  read  arguments  from  the environment variables BZIP2 and\nBZIP, in that order, and will process them before  any  arguments  read\nfrom  the  command line.  This gives a convenient way to supply default\narguments.\n\nCompression is  always  performed,  even  if  the  compressed  file  is\nslightly  larger  than the original.  Files of less than about one hun-\ndred bytes tend to get larger, since the compression  mechanism  has  a\nconstant  overhead  in  the region of 50 bytes.  Random data (including\nthe output of most file compressors) is coded at about  8.05  bits  per\nbyte, giving an expansion of around 0.5%.\n\nAs  a  self-check  for  your protection, bzip2 uses 32-bit CRCs to make\nsure that the decompressed version of a file is identical to the origi-\nnal.   This  guards  against  corruption  of  the  compressed data, and\nagainst undetected  bugs  in  bzip2  (hopefully  very  unlikely).   The\nchances  of  data corruption going undetected is microscopic, about one\nchance in four billion for each file processed.  Be aware, though, that\nthe check occurs upon decompression, so it can only tell you that some-\nthing is wrong.  It can't help you recover  the  original  uncompressed\ndata.   You  can  use  bzip2recover to try to recover data from damaged\nfiles.\n\nReturn values: 0 for a normal exit, 1 for environmental problems  (file\nnot found, invalid flags, I/O errors, &c), 2 to indicate a corrupt com-\npressed file, 3 for an  internal  consistency  error  (eg,  bug)  which\ncaused bzip2 to panic.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "-c --stdout\nCompress or decompress to standard output.\n\n-d --decompress\nForce  decompression.   bzip2,  bunzip2 and bzcat are really the\nsame program, and the decision about what  actions  to  take  is\ndone  on  the  basis of which name is used.  This flag overrides\nthat mechanism, and forces bzip2 to decompress.\n\n-z --compress\nThe complement to -d: forces compression, regardless of the  in-\nvocation name.\n\n-t --test\nCheck  integrity  of the specified file(s), but don't decompress\nthem.  This really performs a  trial  decompression  and  throws\naway the result.\n\n-f --force\nForce overwrite of output files.  Normally, bzip2 will not over-\nwrite existing output files.  Also forces bzip2  to  break  hard\nlinks to files, which it otherwise wouldn't do.\n\nbzip2 normally declines to decompress files which don't have the\ncorrect magic header bytes.  If forced (-f),  however,  it  will\npass  such  files  through unmodified.  This is how GNU gzip be-\nhaves.\n\n-k --keep\nKeep (don't delete) input files during compression or decompres-\nsion.\n\n-s --small\nReduce memory usage, for compression, decompression and testing.\nFiles are decompressed and tested  using  a  modified  algorithm\nwhich  only  requires  2.5 bytes per block byte.  This means any\nfile can be decompressed in 2300 k of memory,  albeit  at  about\nhalf the normal speed.\n\nDuring compression, -s selects a block size of 200 k, which lim-\nits memory use to around the same figure, at the expense of your\ncompression  ratio.   In short, if your machine is low on memory\n(8 megabytes or less), use -s for everything.  See  MEMORY  MAN-\nAGEMENT below.\n\n-q --quiet\nSuppress non-essential warning messages.  Messages pertaining to\nI/O errors and other critical events will not be suppressed.\n\n-v --verbose\nVerbose mode -- show the compression ratio for  each  file  pro-\ncessed.   Further -v's increase the verbosity level, spewing out\nlots of information which is primarily of interest for  diagnos-\ntic purposes.\n\n-h --help\nPrint a help message and exit.\n\n-L --license -V --version\nDisplay the software version, license terms and conditions.\n\n-1 (or --fast) to -9 (or --best)\nSet  the block size to 100 k, 200 k ...  900 k when compressing.\nHas no effect when decompressing.  See MEMORY MANAGEMENT  below.\nThe --fast and --best aliases are primarily for GNU gzip compat-\nibility.  In particular, --fast  doesn't  make  things  signifi-\ncantly faster.  And --best merely selects the default behaviour.\n\n--     Treats  all  subsequent  arguments  as  file names, even if they\nstart with a dash.  This is so you can handle files  with  names\nbeginning with a dash, for example: bzip2 -- -myfilename.\n\n--repetitive-fast --repetitive-best\nThese  flags  are  redundant  in versions 0.9.5 and above.  They\nprovided some coarse control over the behaviour of  the  sorting\nalgorithm  in  earlier  versions,  which  was  sometimes useful.\n0.9.5 and above have an improved algorithm which  renders  these\nflags irrelevant.\n",
                "subsections": []
            },
            "MEMORY MANAGEMENT": {
                "content": "bzip2  compresses  large  files in blocks.  The block size affects both\nthe compression ratio achieved, and the amount  of  memory  needed  for\ncompression  and  decompression.   The  flags -1 through -9 specify the\nblock size to be 100,000 bytes through 900,000 bytes (the default)  re-\nspectively.  At decompression time, the block size used for compression\nis read from the header of the compressed file, and bunzip2 then  allo-\ncates  itself  just  enough memory to decompress the file.  Since block\nsizes are stored in compressed files, it follows that the flags  -1  to\n-9 are irrelevant to and so ignored during decompression.\n\nCompression  and decompression requirements, in bytes, can be estimated\nas:\n\nCompression:   400 k + ( 8 x block size )\n\nDecompression: 100 k + ( 4 x block size ), or\n100 k + ( 2.5 x block size )\n\nLarger block sizes give rapidly diminishing marginal returns.  Most  of\nthe  compression  comes  from the first two or three hundred k of block\nsize, a fact worth bearing in mind when using bzip2 on small  machines.\nIt  is  also  important to appreciate that the decompression memory re-\nquirement is set at compression time by the choice of block size.\n\nFor files compressed with the default 900 k block  size,  bunzip2  will\nrequire  about  3700 kbytes to decompress.  To support decompression of\nany file on a 4 megabyte machine, bunzip2 has an option  to  decompress\nusing approximately half this amount of memory, about 2300 kbytes.  De-\ncompression speed is also halved, so you should use  this  option  only\nwhere necessary.  The relevant flag is -s.\n\nIn  general,  try and use the largest block size memory constraints al-\nlow, since that maximises the compression  achieved.   Compression  and\ndecompression speed are virtually unaffected by block size.\n\nAnother  significant point applies to files which fit in a single block\n-- that means most files you'd encounter using a large block size.  The\namount  of real memory touched is proportional to the size of the file,\nsince the file is smaller than a block.   For  example,  compressing  a\nfile  20,000  bytes  long with the flag -9 will cause the compressor to\nallocate around 7600 k of memory, but only touch 400 k + 20000  *  8  =\n560 kbytes of it.  Similarly, the decompressor will allocate 3700 k but\nonly touch 100 k + 20000 * 4 = 180 kbytes.\n\nHere is a table which summarises the maximum memory usage for different\nblock  sizes.   Also recorded is the total compressed size for 14 files\nof the Calgary Text Compression Corpus totalling 3,141,622 bytes.  This\ncolumn  gives  some  feel  for  how compression varies with block size.\nThese figures tend to understate the advantage of  larger  block  sizes\nfor larger files, since the Corpus is dominated by smaller files.\n\nCompress   Decompress   Decompress   Corpus\nFlag     usage      usage       -s usage     Size\n\n-1      1200k       500k         350k      914704\n-2      2000k       900k         600k      877703\n-3      2800k      1300k         850k      860338\n-4      3600k      1700k        1100k      846899\n-5      4400k      2100k        1350k      845160\n-6      5200k      2500k        1600k      838626\n-7      6100k      2900k        1850k      834096\n-8      6800k      3300k        2100k      828642\n-9      7600k      3700k        2350k      828642\n",
                "subsections": []
            },
            "RECOVERING DATA FROM DAMAGED FILES": {
                "content": "bzip2  compresses files in blocks, usually 900 kbytes long.  Each block\nis handled independently.  If a media or transmission  error  causes  a\nmulti-block  .bz2 file to become damaged, it may be possible to recover\ndata from the undamaged blocks in the file.\n\nThe compressed representation of each block is delimited  by  a  48-bit\npattern, which makes it possible to find the block boundaries with rea-\nsonable certainty.  Each block also carries its own 32-bit CRC, so dam-\naged blocks can be distinguished from undamaged ones.\n\nbzip2recover  is a simple program whose purpose is to search for blocks\nin .bz2 files, and write each block out into its own  .bz2  file.   You\ncan then use bzip2 -t to test the integrity of the resulting files, and\ndecompress those which are undamaged.\n\nbzip2recover takes a single argument, the name of the damaged file, and\nwrites  a number of files \"rec00001file.bz2\", \"rec00002file.bz2\", etc.,\ncontaining the  extracted  blocks.  The output filenames  are  designed\nso  that  the use of wildcards in subsequent processing -- for example,\n\"bzip2 -dc rec*file.bz2 > recovereddata\" -- processes the files in the\ncorrect order.\n\nbzip2recover  should  be  of most use dealing with large .bz2 files, as\nthese will contain many blocks.  It is clearly futile to use it on dam-\naged single-block files, since a damaged block cannot be recovered.  If\nyou wish to minimise any potential data loss through media or transmis-\nsion errors, you might consider compressing with a smaller block size.\n",
                "subsections": []
            },
            "PERFORMANCE NOTES": {
                "content": "The  sorting  phase  of compression gathers together similar strings in\nthe file.  Because of this, files containing very long runs of repeated\nsymbols,  like  \"aabaabaabaab ...\" (repeated several hundred times) may\ncompress more slowly than normal.  Versions 0.9.5 and above  fare  much\nbetter  than  previous  versions  in  this  respect.  The ratio between\nworst-case and average-case compression time is in the region of  10:1.\nFor  previous  versions,  this figure was more like 100:1.  You can use\nthe -vvvv option to monitor progress in great detail, if you want.\n\nDecompression speed is unaffected by these phenomena.\n\nbzip2 usually allocates several megabytes of memory to operate in,  and\nthen  charges  all over it in a fairly random fashion.  This means that\nperformance, both for compressing and decompressing, is largely  deter-\nmined by the speed at which your machine can service cache misses.  Be-\ncause of this, small changes to the code to reduce the miss  rate  have\nbeen  observed  to  give  disproportionately large performance improve-\nments.  I imagine bzip2 will perform best on machines with  very  large\ncaches.\n",
                "subsections": []
            },
            "CAVEATS": {
                "content": "I/O  error  messages  are not as helpful as they could be.  bzip2 tries\nhard to detect I/O errors and exit cleanly, but the details of what the\nproblem is sometimes seem rather misleading.\n\nThis  manual  page pertains to version 1.0.8 of bzip2.  Compressed data\ncreated by this version is entirely forwards and  backwards  compatible\nwith  the  previous  public  releases,  versions  0.1pl2, 0.9.0, 0.9.5,\n1.0.0, 1.0.1, 1.0.2 and above, but with the following exception:  0.9.0\nand  above  can  correctly  decompress multiple concatenated compressed\nfiles.  0.1pl2 cannot do this; it will stop  after  decompressing  just\nthe first file in the stream.\n\nbzip2recover  versions prior to 1.0.2 used 32-bit integers to represent\nbit positions in compressed files, so they could not handle  compressed\nfiles  more  than  512  megabytes  long.   Versions 1.0.2 and above use\n64-bit ints on some platforms which support them  (GNU  supported  tar-\ngets, and Windows).  To establish whether or not bzip2recover was built\nwith such a limitation, run it without arguments.  In any event you can\nbuild  yourself  an unlimited version if you can recompile it with May-\nbeUInt64 set to be an unsigned 64-bit integer.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Julian Seward, jseward@acm.org.\n\nhttps://sourceware.org/bzip2/\n\nThe ideas embodied in bzip2 are due to (at least) the following people:\nMichael  Burrows  and  David Wheeler (for the block sorting transforma-\ntion), David Wheeler (again, for the Huffman coder), Peter Fenwick (for\nthe  structured  coding  model  in  the original bzip, and many refine-\nments), and Alistair Moffat, Radford  Neal  and  Ian  Witten  (for  the\narithmetic  coder  in the original bzip).  I am much indebted for their\nhelp, support and advice.  See the manual in  the  source  distribution\nfor pointers to sources of documentation.  Christian von Roques encour-\naged me to look for faster sorting algorithms, so as to speed  up  com-\npression.  Bela Lubkin encouraged me to improve the worst-case compres-\nsion performance.  Donna Robinson XMLised the documentation.   The  bz*\nscripts  are derived from those of GNU gzip.  Many people sent patches,\nhelped with portability problems, lent machines, gave advice  and  were\ngenerally helpful.\n\nbzip2(1)",
                "subsections": []
            }
        }
    }
}