Linux system management and maintenance -bzip2/bunzip2 command

  

1. The function description compresses and decompresses the file. This command is similar to the “gzip/gunzip” command and can only compress files. For the directory, only all the files in the directory can be compressed. After the compression is completed, a compressed package with the suffix "“.bz2”" is generated in the directory. Bunzip2 is actually a symbolic link to bzip2, which is a soft link, so compression and decompression can be achieved by bzip2. The format is as follows: bzip2 [options] The options for the bzip2 command to be compressed or decompressed and their descriptions are shown in Table 4.30. Table 4.30 Options for bzip2 Command and Descriptions

Option Meaning -d Perform decompression, at this time the option is followed by the file to be decompressed -v Compress or decompress the file, the details are displayed -k bzip2 is compressed or After decompressing, the original file will be deleted. To retain the original file, use this option -f bzip2. When compressing or decompressing, if the output file has the same name as the existing file, the preset will not overwrite the existing file. To override, use this option -t test <;bz2” compressed file integrity - compression level compression level can be selected from 1 to 9, the higher the number, the higher the compression rate 2. For example, compress etc.zip, var.zip, and backup.zip in the /opt directory to set the compression ratio to the highest. At the same time, the original file is not deleted after the compression is completed, and the details of the compression process are displayed. [root@mylinux ~]# bzip2 -9vk /opt/etc.zip /opt/var.zip /opt/backup.zip etc.zip: 1.048:1, 7.633 bits/byte, 4.59% saved, 49490414 in, 4721194 out .var.zip: 1.048:1, 7.633 bits/byte, 4.59% saved, 49490414 in, 2821065 out.backup.zip: 1.046:1, 7.647 bits/byte, 4.42% saved, 8410 in, 8823 out. After compression The corresponding etc.zip.bz2, var.zip.bz2, and backup.zip.bz2 files are generated under /opt.

Copyright © Windows knowledge All Rights Reserved