Linux commands: BZIP2/BUNZIP2 command-compression and decompression

Source: Internet
Author: User
Tags bz2

Gzip/gunzip command

Function description

Similar to the Gizp/gunzip command, compress and decompress files. For directories that can only compress all files in the directory, after compression is complete, a compressed package with ". bz2" suffix is generated in the directory. BUNZIP2 is a soft link for bzip2, so both compression and angular compression can be done through bzip2. Use the following:

bzip2 [options] to compress the extracted files

Common parameters

Options Description
-D Decompression of compressed Files (equivalent to the decompression function of Bunzip)
-K Keep the original file
-V Show details when compressing or decompressing a file
-F bzip2 when compressing and decompressing, if the output file has the same name as an existing file, the preset does not overwrite the existing file. To overwrite, use this option
-V For each compressed and uncompressed document, the corresponding file name and compression ratio are displayed
-T Test the integrity of a compressed file
- # Compression level, 1-9, the larger the number, the higher the compression rate

Example

Command Installation & compression Demo

[Email protected] app]# bzip2 shell.txt #提示命令没有找到

-BASH:BZIP2: Command not found

[Email protected] app]# yum-y install bzip2 #安装bzip2命令

[Email protected] app]# ll-h #shell. txt file 141k

Total dosage 168K

-rw-r--r--. 1 root root 181 November 17:34 99.sh

-RW-------. 1 root root 12K November 14:08 messages

-rw-r--r--. 1 root root 1.2K November 15:17 messages2.gz

-rw-r--r--. 1 root root 1.2K November 14:36 messages.gz

-rw-r--r--. 1 root root 141K November 10:17 Shell.txt

[Email protected] app]# bzip2 shell.txt #提示命令没有找到

[Email protected] app]# ll-h #shell. txt compression changed from 141k to 48k, the original file shell.txt.

Total dosage 72K

-rw-r--r--. 1 root root 181 November 17:34 99.sh

-RW-------. 1 root root 12K November 14:08 messages

-rw-r--r--. 1 root root 1.2K November 15:17 messages2.gz

-rw-r--r--. 1 root root 1.2K November 14:36 messages.gz

-rw-r--r--. 1 root root 48K November 10:17 shell.txt.bz2

Use the-K parameter to retain the original file decompression

[[email protected] app]# bzip2-d-K shell.txt.bz2   #使用-D parameter compression, the-K parameter retains the original file

[[email protected] app]# ll-h                            

use Bzcat to find out what 's on your file

[Email protected] app]# bzcat shell.txt.bz2 | more


The following commands and bzip2 are used essentially the same way, and the compressed file has an. xz extension.

Xz/unxz/xzcat Command Introduction

bzip2 [OPTION] ... FILE ...

-k:keep, keep the original documents;

-D: Unzip

-#:1-9, compression ratio, default is 6;

Xzcat: View the contents of the text file without displaying the expanded condition;



Learn from:

Karst "Progressive Linux"

Marco Linux



This article is from the "Zhao Dongwei blog" blog, make sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1875805

Linux commands: BZIP2/BUNZIP2 command-compression and decompression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.