您的位置 首页 > 数码极客

【压缩包后缀】压缩工具gzip、bzip2、xz

Linux的典型压缩文件扩展名如下:

.zip,gz、 bz2、xz,

压缩文件在解压缩后可能与源文件大小不匹配。

gzip压缩工具

  • 命令格式: gzip 文件名
  • 不能压缩目录
[root@centos01 d6]# ls -lh 1.txt -rw-r--r--. 1 root root 1.3M Sep 30 07:38 1.txt [root@centos01 d6]# [root@centos01 d6]# gzip 1.txt # 压缩1.txt [root@centos01 d6]# ls 1. [root@centos01 d6]# ls -lh 1. -rw-r--r--. 1 root root 358K Sep 30 07:38 1. [root@centos01 d6]# gzip -d 1. # 解压缩1. [root@centos01 d6]# ls 1.txt [root@centos01 d6]# gunzip 1. # gunzip解压1. [root@centos01 d6]# ls 1.txt [root@centos01 d6]# gzip -1 1.txt # 默认压缩级别6,范围1-9 [root@centos01 d6]# ls 1. [root@centos01 d6]# zcat 1. | head -n 5 # 查看压缩文件(加压后打开) # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no # /etc/lvm file. # # Refer to 'man lvm.conf' for further information including the file layout. [root@centos01 d6]# gzip -c 1.txt > 1. # 压缩时不删除文件,并输出到指定文件 [root@centos01 d6]# ls 1.txt 1. [root@centos01 d6]# gunzip -c 1. > 1.cp.txt # 不删除压缩文件,解压为指定文件 [root@centos01 d6]# ls 1.cp.txt 1.txt 1.

bzip2压缩工具

  • 安装工具: yum install -y bzip2
  • 命令格式: bzip2 文件名
  • 不支持压缩目录
[root@centos01 d6]# bzip2 1.txt # 压缩1.txt [root@centos01 d6]# ls -l total 1840 -rw-r--r--. 1 root root 1361328 Sep 30 07:50 1.cp.txt -rw-r--r--. 1 root root 149229 Sep 30 07:38 1. -rw-r--r--. 1 root root 365757 Sep 30 07:48 1. [root@centos01 d6]# bzip2 -d 1. # 解压缩1. [root@centos01 d6]# ls 1.cp.txt 1.txt 1. [root@centos01 d6]# bzip2 1.txt [root@centos01 d6]# bunzip2 1. # 解压缩1. [root@centos01 d6]# bzip2 -c 1.txt > 1. # 压缩时不删除文件,并输出到指定文件 [root@centos01 d6]# ls 1.cp.txt 1. 1.txt 1. [root@centos01 d6]# bzip2 -d -c 1. > 1.c # 压缩时不删除文件,并输出到指定文件 [root@centos01 d6]# ls 1.c 1.cp.txt 1. 1.txt 1. [root@centos01 d6]# bzip2 -9 1.cp.txt # -9级别,范围1-9 [root@centos01 d6]# ls 1.c 1.cp. 1. 1.txt 1. [root@centos01 d6]# bzcat 1. | head -n 10 # bz2压缩文件查看 # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no # /etc/lvm file. # # Refer to 'man lvm.conf' for further information including the file layout. # # Refer to 'man lvm.conf' for information about how settings configured in # this file are combined with built-in values and command line options to # arrive at the final values used by LVM. #

xz压缩工具

  • 命令格式: xz 2.txt
  • 使用基本和gzip、bzip2一样
[root@centos01 d6]# xz 2.txt [root@centos01 d6]# xz -d 2. [root@centos01 d6]# xz 2.txt [root@centos01 d6]# unxz 2. [root@centos01 d6]# xz -c 2.txt > 2.cp. [root@centos01 d6]# xz -d -c 2.cp. > 2.cp.txt [root@centos01 d6]# xz 2.txt [root@centos01 d6]# xzcat 2. | head -n 10 # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no # /etc/lvm file. # # Refer to 'man lvm.conf' for further information including the file layout. # # Refer to 'man lvm.conf' for information about how settings configured in # this file are combined with built-in values and command line options to # arrive at the final values used by LVM. #

关于作者: admin

无忧经验小编鲁达,内容侵删请Email至wohenlihai#qq.com(#改为@)

热门推荐