Centos7安装compress压缩工具

centos安装compress压缩工具

压缩后的档案可以以 uncompress 解压。若要将数个档案压成一个压缩档,必须先将档案 tar 起来再压缩。由于 gzip 可以产生更理想的压缩比例,一般人多已改用 gzip 为档案压缩工具。

安装compress

[root@localhost ~]# yum -y install ncompress
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package ncompress.x86_64 0:4.2.4.4-3.1.el7_8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================
 Package          Arch          Version                   Repository   Size
============================================================================
Installing:
 ncompress        x86_64        4.2.4.4-3.1.el7_8         base         27 k

Transaction Summary
============================================================================
Install  1 Package

Total download size: 27 k
Installed size: 35 k
Downloading packages:
ncompress-4.2.4.4-3.1.el7_8.x86_64.rpm                 |  27 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ncompress-4.2.4.4-3.1.el7_8.x86_64                       1/1 
  Verifying  : ncompress-4.2.4.4-3.1.el7_8.x86_64                       1/1 

Installed:
  ncompress.x86_64 0:4.2.4.4-3.1.el7_8                                      

Complete!
[root@localhost ~]# compress -V                           #查看安装版本
ompress version: (N)compress 4.2.4.4, compiled: Tue Jun 23 15:37:14 UTC 2020
Compile options:
        FAST, DIRENT, 
        REGISTERS=20 IBUFSIZ=8192, OBUFSIZ=1024, BITS=16

Author version 4.2 (Speed improvement & source cleanup):
     Peter Jannesen  (peter@ncs.nl)

Author version 4.1 (Added recursive directory compress):
     Dave Mack  (csu@alembic.acs.com)

Authors version 4.0 (World release in 1985):
     Spencer W. Thomas, Jim McKie, Steve Davies,
     Ken Turkowski, James A. Woods, Joe Orost
[root@localhost ~]# compress -h
Unknown flag: 'h'; 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.

使用参数:

  • c 输出结果至标准输出设备(一般指荧幕)
  • f 强迫写入档案,若目的档已经存在,则会被覆盖 (force)
  • v 将程序执行的讯息印在荧幕上 (verbose)
  • b 设定共同字串数的上限,以位元计算,可以设定的值为 9 至 16 bits 。由于值越大,能使用的共同字串就 越多,压缩比例就越大,所以一般使用预设值 16 bits (bits)
  • d 将压缩档解压缩
  • V 列出版本讯息
  • r 递归压缩目录下所有文件

压缩文件

a.txt压缩为a.txt.Z文件

[root@localhost ~]# ls
a.txt
[root@localhost ~]# compress -f a.txt 
[root@localhost ~]# ls
a.txt.Z

解压文件

将刚压缩的文件解压

[root@localhost ~]# ls
a.txt.Z
[root@localhost ~]# compress -d a.txt.Z 
[root@localhost ~]# ls
a.txt

压缩目录下的文件

强制递归压缩目录使用-r递归-f压缩文件

[root@localhost ~]# ls
a.txt
[root@localhost ~]# compress -rf /root/a.txt 
[root@localhost ~]# ls
a.txt.Z
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值