linux 操作系统下的compress命令介绍和使用案例

linux 操作系统下的compress命令介绍和使用案例

compress命令是Linux系统中用于文件压缩的一个工具,主要使用Lempel-Ziv-Welch (LZW)算法进行数据压缩。压缩后,文件的扩展名将变为“.Z”。虽然compress命令在历史上有其重要性,但在现代Linux系统中,它已经被更高效的压缩工具如gzip和bzip2所取代

使用方法

基本语法

bash 
compress [选项] [文件名]

安装部署:

root@meng:~# which compress

root@meng:~# compress

Command 'compress' not found, but can be installed with:

apt install ncompress

root@meng:~# apt install ncompress

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

The following NEW packages will be installed:

ncompress

0 upgraded, 1 newly installed, 0 to remove and 224 not upgraded.

Need to get 22.0 kB of archives.

After this operation, 58.4 kB of additional disk space will be used.

Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/universe amd64 ncompress amd64 4.2.4.6-5 [22.0 kB]

Fetched 22.0 kB in 1s (23.0 kB/s)

Selecting previously unselected package ncompress.

(Reading database ... 75125 files and directories currently installed.)

Preparing to unpack .../ncompress_4.2.4.6-5_amd64.deb ...

Unpacking ncompress (4.2.4.6-5) ...

Setting up ncompress (4.2.4.6-5) ...

Processing triggers for man-db (2.10.2-1) ...

Scanning processes...

Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

root@meng:~# compress --help

Unknown flag: '-'; Usage: compress [-dfhvcVr] [-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.

-h This help output.

-v Write compression statistics.

-V Output version and compile options.

-r Recursive. If a filename is a directory, descend

into it and compress everything in it.

命令案例:

root@meng:~# more m1.txt

hello men

g

hello meng

g

Hello World

This is a test

HelloWorld

Hello World

This is a test

root@meng:~# compress -v m1.txt

m1.txt: -- replaced with m1.txt.Z Compression: 21.10%

root@meng:~# ls

f1.txt.bz2 f2.txt.bz2 m1.txt.Z m2.txt meng.txt meng.txt.bz2 rec00001f1.txt s1.txt s2.txt snap tmp

root@meng:~# uncompress -v m1.txt.Z

m1.txt.Z: 21.1% -- replaced with m1.txt

root@meng:~# ls

f1.txt.bz2 f2.txt.bz2 m1.txt m2.txt meng.txt meng.txt.bz2 rec00001f1.txt s1.txt s2.txt snap tmp

root@meng:~#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lisanmengmeng

蚊子腿也是肉

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值