Linux操作系统的压缩、解压缩工具介绍
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.compress/uncompress命令常用参数
Linux compress命令: 是一个相当古老的 unix 档案压缩指令,压缩后的档案会加上一个 .Z 延伸档名以区别未压缩的档案,压缩后的档案可以以 uncompress 解压。若要将数个档案压成一个压缩档,必须先将档案 tar 起来再压缩。由于 gzip 可以产生更理想的压缩比例,一般人多已改用 gzip 为档案压缩工具。 compress [-dfvcVr] [-b maxbits] [file ...] -d: 解压缩,相当于uncompress -c: 结果输出至标准输出,不删除原文件
-v:
显示详情 uncompress 解压缩 zcat file.Z >file
1>.安装commpress/uncompress软件包

[[email protected] ~]# yum -y install ncompress.x86_64 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.tuna.tsinghua.edu.cn * extras: mirrors.aliyun.com * updates: mirror.bit.edu.cn Resolving Dependencies --> Running transaction check ---> Package ncompress.x86_64 0:4.2.4.4-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================== Installing: ncompress x86_64 4.2.4.4-3.el7 base 26 k Transaction Summary =================================================================================================================================== Install 1 Package Total download size: 26 k Installed size: 35 k Downloading packages: ncompress-4.2.4.4-3.el7.x86_64.rpm | 26 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : ncompress-4.2.4.4-3.el7.x86_64 1/1 Verifying : ncompress-4.2.4.4-3.el7.x86_64 1/1 Installed: ncompress.x86_64 0:4.2.4.4-3.el7 Complete! [[email protected] ~]#
2>.压缩文件
[[email protected] ~]# ll /var/log/messages -h -rw------- 1 root root 89K Dec 13 17:20 /var/log/messages [[email protected] ~]# [[email protected] ~]# for _ in `seq 1000`;do cat /var/log/messages >> /root/message;done #创建测试压缩的文件 [[email protected] ~]# [[email protected] ~]# ll -h total 87M -rw-r--r-- 1 root root 87M Dec 13 17:45 message [[email protected] ~]# [[email protected] ~]# compress message #compress命令压缩文件后会将源文件删除,并在源文件名称后缀中多了一个".Z" [[email protected] ~]# [[email protected] ~]# ll -h total 18M -rw-r--r-- 1 root root 18M Dec 13 17:45 message.Z #文件的确是变小啦。 [[email protected] ~]# [[email protected] ~]#
3>.解压文件
[[email protected] ~]# ll -h total 18M -rw-r--r-- 1 root root 18M Dec 13 17:45 message.Z [[email protected] ~]# [[email protected] ~]# uncompress message.Z [[email protected] ~]# [[email protected] ~]# ll -h total 87M -rw-r--r-- 1 root root 87M Dec 13 17:45 message [[email protected] ~]# [[email protected] ~]#
4>."-c"参数使用案例
[[email protected] ~]# ll -h total 87M -rw-r--r-- 1 root root 87M Dec 13 17:45 message [[email protected] ~]# [[email protected] ~]# compress -c message > message.Z #不建议将压缩结果直接输出到标准输出,因为打印在标准输出咱们人为是读不懂的,因此可以考虑重定向,这样即压缩来源文件,也达到来不删除源文件的好处。 [[email protected] ~]# [[email protected] ~]# ll -h total 104M -rw-r--r-- 1 root root 87M Dec 13 17:45 message -rw-r--r-- 1 root root 18M Dec 13 18:07 message.Z [[email protected] ~]#
5>.zcat使用案例

[[email protected] ~]# ll total 106344 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z [[email protected] ~]# [[email protected] ~]# zcat message.Z #预览压缩内容但并不解压 ...... Dec 13 15:01:01 node101 systemd: Started Session 55 of user root. Dec 13 15:01:01 node101 systemd: Removed slice User Slice of root. Dec 13 15:41:07 node101 systemd: Starting Cleanup of Temporary Directories... Dec 13 15:41:07 node101 systemd: Started Cleanup of Temporary Directories. Dec 13 16:01:01 node101 systemd: Created slice User Slice of root. Dec 13 16:01:01 node101 systemd: Started Session 56 of user root. Dec 13 16:01:01 node101 systemd: Removed slice User Slice of root. Dec 13 16:39:05 node101 sshd[333]: Accepted password for root from 172.30.1.2 port 50754 ssh2 Dec 13 16:39:05 node101 systemd: Created slice User Slice of root. Dec 13 16:39:05 node101 systemd-logind: New session 57 of user root. Dec 13 16:39:05 node101 systemd: Started Session 57 of user root. Dec 13 16:42:32 node101 chronyd[3582]: Source 116.203.151.74 replaced with 119.28.183.184 Dec 13 16:45:45 node101 chronyd[3582]: Selected source 119.28.183.184 Dec 13 16:45:45 node101 chronyd[3582]: System clock wrong by 165882.562596 seconds, adjustment started Dec 13 17:01:01 node101 systemd: Started Session 58 of user root. Dec 13 17:19:27 node101 chronyd[3582]: Source 144.76.76.107 replaced with 193.182.111.141 Dec 13 17:20:27 node101 sshd[2691]: Accepted password for root from 172.30.1.2 port 51751 ssh2 Dec 13 17:20:27 node101 systemd-logind: New session 59 of user root. Dec 13 17:20:27 node101 systemd: Started Session 59 of user root. [[email protected] ~]# [[email protected] ~]# ll total 106344 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z [[email protected] ~]#
6>.compress也支持交互式压缩
[[email protected] ~]# ll total 106344 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# compress > test.Z #按住"ctrl+d"就会结束命令行输出 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# ll total 106348 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z -rw-r--r-- 1 root root 32 Dec 13 18:13 test.Z [[email protected] ~]# [[email protected] ~]# zcat test.Z | wc -c #重复的次数越多,压缩比例就越高 320 [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# ll total 106348 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z -rw-r--r-- 1 root root 32 Dec 13 18:13 test.Z [[email protected] ~]# [[email protected] ~]#
7>."-d"参数介绍
[[email protected] ~]# ll total 106348 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z -rw-r--r-- 1 root root 32 Dec 13 18:13 test.Z [[email protected] ~]# [[email protected] ~]# [[email protected] ~]# compress -d test.Z #解压"test.Z"文件 [[email protected] ~]# [[email protected] ~]# ll total 106348 -rw-r--r-- 1 root root 90740000 Dec 13 17:45 message -rw-r--r-- 1 root root 18150727 Dec 13 18:07 message.Z -rw-r--r-- 1 root root 320 Dec 13 18:13 test [[email protected] ~]# [[email protected] ~]#
8>.compress命令支持将命令标准输出进行压缩
[[email protected] ~]# dmesg | compress > dmesg.Z [[email protected] ~]# [[email protected] ~]# ll total 24 -rw-r--r-- 1 root root 21010 Dec 13 18:22 dmesg.Z [[email protected] ~]# [[email protected] ~]# uncompress dmesg.Z [[email protected] ~]# [[email protected] ~]# ll total 48 -rw-r--r-- 1 root root 46804 Dec 13 18:22 dmesg [[email protected] ~]# [[email protected] ~]#
9>.更多compress压缩命令帮助信息

[[email protected] ~]# compress --help Unknown flag: '-'; Usage: compress [-dfvcVr] [-b maxbits] [file ...] -d If given, decompression is done instead. -c Write output on stdout, don't remove original. -b Parameter limits the max number of bits/code. -f Forces output file to be generated, even if one already. exists, and even if no space is saved by compressing. If -f is not used, the user will be prompted if stdin is. a tty, otherwise, the output file will not be overwritten. -v Write compression statistics. -V Output vesion and compile options. -r Recursive. If a filename is a directory, descend into it and compress everything in it. [[email protected] ~]#
[[email protected] ~]# man compress
二.gzip/gunzip(gzip完胜compress)
gzip [OPTION]... FILE ...
-d:
解压缩,相当于gunzip
-c:
结果输出至标准输出,保留原文件不改变
-num:
这个"num"对应的数字范围是:1-9,指定压缩比,值越大压缩比越大,默认压缩比例是6,可参考下面的实验结果。
zcat:
不显式解压缩的前提下查看文本文件内容
1>.压缩同样文件对比compress和gzip的压缩比例
[[email protected] ~]# for _ in `seq 10000`;do cat /var/log/messages >> /root/message;done [[email protected] ~]# [[email protected] ~]# ll -h total 877M -rw-r--r-- 1 root root 877M Dec 14 01:57 message [[email protected] ~]# [[email protected] ~]# cp message f1.txt [[email protected] ~]# [[email protected] ~]# cp message f2.txt [[email protected] ~]# [[email protected] ~]# ll -h total 2.6G -rw-r--r-- 1 root root 877M Dec 14 01:59 f1.txt -rw-r--r-- 1 root root 877M Dec 14 01:59 f2.txt -rw-r--r-- 1 root root 877M Dec 14 01:57 message [[email protected] ~]# [[email protected] ~]# compress f1.txt [[email protected] ~]# [[email protected] ~]# gzip f2.txt [[email protected] ~]# [[email protected] ~]# ll -h total 1.2G -rw-r--r-- 1 root root 171M Dec 14 01:59 f1.txt.Z -rw-r--r-- 1 root root 164M Dec 14 01:59 f2.txt.gz -rw-r--r-- 1 root root 877M Dec 14 01:57 message [[email protected] ~]# [[email protected] ~]#
2>.解压文件
[[email protected] ~]# ll -h total 1.2G -rw-r--r-- 1 root root 171M Dec 14 01:59 f1.txt.Z -rw-r--r-- 1 root root 164M Dec 14 01:59 f2.txt.gz -rw-r--r-- 1 root root 877M Dec 14 01:57 message [[email protected] ~]# [[email protected] ~]# gunzip f2.txt.gz [[email protected] ~]# [[email protected] ~]# ll -h total 1.9G -rw-r--r-- 1 root root 171M Dec 14 01:59 f1.txt.Z -rw-r--r-- 1 root root 877M Dec 14 01:59 f2.txt -rw-r--r-- 1 root root 877M Dec 14 01:57 message [[email protected] ~]# [[email protected] ~]#
3>.指定压缩级别(默认压缩级别在6左右)
[[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# cp message f1.txt [[email protected] ~]# cp message f2.txt [[email protected] ~]# cp message f3.txt [[email protected] ~]# cp message f4.txt [[email protected] ~]# cp message f5.txt [[email protected] ~]# cp message f6.txt [[email protected] ~]# cp message f7.txt [[email protected] ~]# cp message f8.txt [[email protected] ~]# cp message f9.txt [[email protected] ~]# cp message f10.txt [[email protected] ~]# [[email protected] ~]# ll -h total 8.3G -rw-r--r--. 1 root root 768M Dec 16 18:21 f10.txt -rw-r--r--. 1 root root 768M Dec 16 18:19 f1.txt -rw-r--r--. 1 root root 768M Dec 16 18:19 f2.txt -rw-r--r--. 1 root root 768M Dec 16 18:19 f3.txt -rw-r--r--. 1 root root 768M Dec 16 18:19 f4.txt -rw-r--r--. 1 root root 768M Dec 16 18:20 f5.txt -rw-r--r--. 1 root root 768M Dec 16 18:20 f6.txt -rw-r--r--. 1 root root 768M Dec 16 18:20 f7.txt -rw-r--r--. 1 root root 768M Dec 16 18:20 f8.txt -rw-r--r--. 1 root root 768M Dec 16 18:21 f9.txt -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# gzip -1 f1.txt [[email protected] ~]# gzip -2 f2.txt [[email protected] ~]# gzip -3 f3.txt [[email protected] ~]# gzip -4 f4.txt [[email protected] ~]# gzip -5 f5.txt [[email protected] ~]# gzip -6 f6.txt [[email protected] ~]# gzip -7 f7.txt [[email protected] ~]# gzip -8 f8.txt [[email protected] ~]# gzip -9 f9.txt [[email protected] ~]# [[email protected] ~]# gzip f10.txt [[email protected] ~]# [[email protected] ~]# ll -h total 2.3G -rw-r--r--. 1 root root 149M Dec 16 18:21 f10.txt.gz -rw-r--r--. 1 root root 173M Dec 16 18:19 f1.txt.gz -rw-r--r--. 1 root root 168M Dec 16 18:19 f2.txt.gz -rw-r--r--. 1 root root 166M Dec 16 18:19 f3.txt.gz -rw-r--r--. 1 root root 154M Dec 16 18:19 f4.txt.gz -rw-r--r--. 1 root root 151M Dec 16 18:20 f5.txt.gz -rw-r--r--. 1 root root 149M Dec 16 18:20 f6.txt.gz -rw-r--r--. 1 root root 148M Dec 16 18:20 f7.txt.gz -rw-r--r--. 1 root root 146M Dec 16 18:20 f8.txt.gz -rw-r--r--. 1 root root 146M Dec 16 18:21 f9.txt.gz -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]#
4>."-c"选项使用案例
[[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# gzip -c message > message.gz #结果输出至标准输出,保留原文件不改变 [[email protected] ~]# [[email protected] ~]# ll -h total 917M -rw-r--r--. 1 root root 768M Dec 16 18:18 message -rw-r--r--. 1 root root 149M Dec 16 18:45 message.gz [[email protected] ~]# [[email protected] ~]#
5>.查看gzip的帮助信息

[[email protected] ~]# gzip --help Usage: gzip [OPTION]... [FILE]... Compress or uncompress FILEs (by default, compress FILES in-place). Mandatory arguments to long options are mandatory for short options too. -c, --stdout write on standard output, keep original files unchanged -d, --decompress decompress -f, --force force overwrite of output file and compress links -h, --help give this help -l, --list list compressed file contents -L, --license display software license -n, --no-name do not save or restore the original name and time stamp -N, --name save or restore the original name and time stamp -q, --quiet suppress all warnings -r, --recursive operate recursively on directories -S, --suffix=SUF use suffix SUF on compressed files -t, --test test compressed file integrity -v, --verbose verbose mode -V, --version display version number -1, --fast compress faster -9, --best compress better --rsyncable Make rsync-friendly archive With no FILE, or when FILE is -, read standard input. Report bugs togzip@gnu.org>. [[email protected] ~]# [[email protected] ~]#
[[email protected] ~]# man gzip
三.bzip2/bunzip2/bzcat(功能要比gzip压缩还要强,比如httpd官方网站的很多压缩包都是基于bzip2压缩方式的,缺点就是压缩时间较长)
bzip2 [OPTION]... FILE ...
-k:keep,
保留原文件 -d:
解压缩 -#:1-9,
压缩比,默认为9
bzcat:
不显式解压缩的前提下查看文本文件内容
1>.安装bzip2软件包

[[email protected] ~]# yum -y install bzip2 Loaded plugins: fastestmirror Determining fastest mirrors * base: mirror.bit.edu.cn * extras: mirror.bit.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/4): base/7/x86_64/group_gz | 165 kB 00:00:00 (2/4): extras/7/x86_64/primary_db | 153 kB 00:00:00 (3/4): base/7/x86_64/primary_db | 6.0 MB 00:00:00 (4/4): updates/7/x86_64/primary_db | 5.8 MB 00:00:11 Resolving Dependencies --> Running transaction check ---> Package bzip2.x86_64 0:1.0.6-13.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================== Installing: bzip2 x86_64 1.0.6-13.el7 base 52 k Transaction Summary =================================================================================================================================== Install 1 Package Total download size: 52 k Installed size: 82 k Downloading packages: bzip2-1.0.6-13.el7.x86_64.rpm | 52 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : bzip2-1.0.6-13.el7.x86_64 1/1 Verifying : bzip2-1.0.6-13.el7.x86_64 1/1 Installed: bzip2.x86_64 0:1.0.6-13.el7 Complete! [[email protected] ~]#
2>.bzip2对比gzip最好压缩比例
[[email protected] ~]# ll total 786088 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# cp message f1.txt [[email protected] ~]# [[email protected] ~]# cp message f2.txt [[email protected] ~]# [[email protected] ~]# ll -h total 2.3G -rw-r--r--. 1 root root 768M Dec 16 18:49 f1.txt -rw-r--r--. 1 root root 768M Dec 16 18:49 f2.txt -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# gzip -9 f1.txt [[email protected] ~]# [[email protected] ~]# bzip2 f2.txt [[email protected] ~]# [[email protected] ~]# ll -h total 937M -rw-r--r--. 1 root root 146M Dec 16 18:49 f1.txt.gz -rw-r--r--. 1 root root 23M Dec 16 18:49 f2.txt.bz2 -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]#
3>."-k"参数使用案例
[[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# bzip2 -k message #压缩时并不会删除源文件 [[email protected] ~]# [[email protected] ~]# ll -h total 791M -rw-r--r--. 1 root root 768M Dec 16 18:18 message -rw-r--r--. 1 root root 23M Dec 16 18:18 message.bz2 [[email protected] ~]# [[email protected] ~]#
4>."-d"参数介绍
[[email protected] ~]# ll total 23256 -rw-r--r--. 1 root root 23810529 Dec 16 18:18 message.bz2 [[email protected] ~]# [[email protected] ~]# bzip2 -d message.bz2 [[email protected] ~]# [[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# ll total 786088 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message [[email protected] ~]#
5>.bzcat命令可以查看bzip2压缩后的文件
[[email protected] ~]# ll total 809344 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message -rw-r--r--. 1 root root 23810529 Dec 16 18:18 message.bz2 [[email protected] ~]# [[email protected] ~]# bzcat message.bz2 #在不解压缩的前提下查看文件内容 Dec 16 18:03:45 node101 kernel: pci 0000:00:01.0: PCI bridge to [bus 01] Dec 16 18:03:45 node101 kernel: pci 0000:00:01.0: bridge window [io 0x6000-0x7fff] Dec 16 18:03:45 node101 kernel: pci 0000:00:01.0: bridge window [mem 0xe2000000-0xedffffff] Dec 16 18:03:45 node101 kernel: pci 0000:00:01.0: bridge window [mem 0xb0000000-0xdfffffff 64bit pref] Dec 16 18:03:45 node101 kernel: pci 0000:00:0a.0: PCI bridge to [bus 02] .......
6>.查看帮助信息

[[email protected] ~]# bzip2 --help bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010. usage: bzip2 [flags and input files in any order] -h --help print this message -d --decompress force decompression -z --compress force compression -k --keep keep (don't delete) input files -f --force overwrite existing output files -t --test test compressed file integrity -c --stdout output to standard out -q --quiet suppress noncritical error messages -v --verbose be verbose (a 2nd -v gives more) -L --license display software version & license -V --version display software version & license -s --small use less memory (at most 2500k) -1 .. -9 set block size to 100k .. 900k --fast alias for -1 --best alias for -9 If invoked as `bzip2', default action is to compress. as `bunzip2', default action is to decompress. as `bzcat', default action is to decompress to stdout. If no file names are given, bzip2 compresses or decompresses from standard input to standard output. You can combine short flags, so `-v -4' means the same as -v4 or -4v, &c. [[email protected] ~]#
[[email protected] ~]# man bzip2
四.xz/unxz/xzcat(压缩比上面几种压缩比例都强,linux 内核软件包官方使用的就是这种压缩方式)
xz [OPTION]... FILE ...
-k: keep
保留原文件 -d:
解压缩 -num:
1-9,压缩比,默认为6
unxz file.xz 解压缩
xzcat:
不显式解压缩的前提下查看文本文件内容
1>."-k"参数使用案例
[[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# ll total 786088 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# xz -k message #压缩时可以保存源文件 [[email protected] ~]# [[email protected] ~]# ll total 786220 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message -rw-r--r--. 1 root root 131092 Dec 16 18:18 message.xz [[email protected] ~]# [[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message -rw-r--r--. 1 root root 129K Dec 16 18:18 message.xz [[email protected] ~]#
2>."-d"参数使用案例
[[email protected] ~]# ll total 786220 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message.log -rw-r--r--. 1 root root 131092 Dec 16 18:18 message.xz [[email protected] ~]# [[email protected] ~]# xz -d message.xz #解压文件 [[email protected] ~]# [[email protected] ~]# ll total 1572176 -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message.log [[email protected] ~]# [[email protected] ~]#
3>.压缩比例对比(随着压缩的比例越大,耗费的时间就越长,默认为6)
[[email protected] ~]# ll -h total 768M -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# cp message f1.txt [[email protected] ~]# cp message f2.txt [[email protected] ~]# cp message f3.txt [[email protected] ~]# cp message f4.txt [[email protected] ~]# cp message f5.txt [[email protected] ~]# cp message f6.txt [[email protected] ~]# cp message f7.txt [[email protected] ~]# cp message f8.txt [[email protected] ~]# cp message f9.txt [[email protected] ~]# cp message f10.txt [[email protected] ~]# [[email protected] ~]# ll -h total 7.5G -rw-r--r--. 1 root root 768M Dec 17 04:14 f10.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f1.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f2.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f3.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f4.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f5.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f6.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f7.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f8.txt -rw-r--r--. 1 root root 768M Dec 17 04:14 f9.txt -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# xz -1 f1.txt [[email protected] ~]# xz -2 f2.txt [[email protected] ~]# xz -3 f3.txt [[email protected] ~]# xz -4 f4.txt [[email protected] ~]# xz -5 f5.txt [[email protected] ~]# xz -6 f6.txt [[email protected] ~]# xz -7 f7.txt [[email protected] ~]# xz -8 f8.txt [[email protected] ~]# xz -9 f9.txt [[email protected] ~]# xz f10.txt [[email protected] ~]# [[email protected] ~]# ll -h total 769M -rw-r--r--. 1 root root 129K Dec 17 07:33 f10.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:32 f1.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:32 f2.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:32 f3.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f4.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f5.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f6.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f7.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f8.txt.xz -rw-r--r--. 1 root root 129K Dec 17 07:33 f9.txt.xz -rw-r--r--. 1 root root 768M Dec 16 18:18 message [[email protected] ~]# [[email protected] ~]# ll #最好以字节显示,不然真看不出差别了 total 787408 -rw-r--r--. 1 root root 131092 Dec 17 07:33 f10.txt.xz -rw-r--r--. 1 root root 132040 Dec 17 07:32 f1.txt.xz -rw-r--r--. 1 root root 131956 Dec 17 07:32 f2.txt.xz -rw-r--r--. 1 root root 131940 Dec 17 07:32 f3.txt.xz -rw-r--r--. 1 root root 131928 Dec 17 07:33 f4.txt.xz -rw-r--r--. 1 root root 131572 Dec 17 07:33 f5.txt.xz -rw-r--r--. 1 root root 131092 Dec 17 07:33 f6.txt.xz -rw-r--r--. 1 root root 131092 Dec 17 07:33 f7.txt.xz -rw-r--r--. 1 root root 131092 Dec 17 07:33 f8.txt.xz -rw-r--r--. 1 root root 131092 Dec 17 07:33 f9.txt.xz -rw-r--r--. 1 root root 804950000 Dec 16 18:18 message [[email protected] ~]#