linux压缩命令_每天一条Linux命令(20) xz (文件解压缩)

b369b914eb301ac1b90bb6689a0dcdaf.png


相信大家一定对命令 xz 感到陌生,我也是,在第一次遇到这种格式的文件压缩包时,00849ba49136578d8e99420cbe8313bf.png我竟不知如何去解压

915c0429490eda0e7413d5c408204b7f.png

怎么办、怎么办,此时鼠标已不受控制,默默的移向了google。

cb41f7f9843983c6885269782161ea6a.png

事情经的经过就是这样,其实事发挺突然的,要不是怕遇到熟人,我必须整两句,趁现在没人就来说说这个 xz


xz是一个使用LZMA压缩算法的无损数据压缩文件格式。和gzip与bzip2一样,同样支持多文件压缩,但是约定不能将多于一个的目标文件压缩进同一个档案文件。相反,xz通常作为一种归档文件自身的压缩格式,例如使用tar或cpioUnix程序创建的归档。xz在GNU coreutils(版本7.1或更新) 中被使用。xz作为压缩软件包被收录在Fedora(自Fedora 12起),Arch Linux,FreeBSD, Slackware Linux,CRUX和Funtoo中等。


xz压缩的优势:

同一文件,tar.xz格式比tar.gz格式小了三分之一!


语法:

xz [选项] [参数]

主要参数说明:

  • -z --compress   # 强制压缩

  • -d --decompress  # 解压缩

  • -t --test  # 测试压缩文件的完整性

  • -k --keep  # 压缩或解压时保持源文件不被删除

  • -l --list  # 列出有关.xz文件的信息

  • -0~9 # 指定压缩率,默认为6;

  • -h --help  # 显示这个简洁的帮助并退出

  • -H --long-help # 显示更多帮助(还列出了高级选项)

  • -V --version # 显示版本号并退出


案例:

压缩图片pandas.png 压缩成功后生成pandas.png.xz ,源文件会被删除

[root@master test03]# lspandas.png[root@master test03]# xz pandas.png [root@master test03]# lspandas.png.xz[root@master test03]# 

解压 pandas.png.xz 并使用-k参数保持源文件不被删除

[root@master test03]# xz -dk pandas.png.xz [root@master test03]# lspandas.png  pandas.png.xz[root@master test03]# 

使用参数 -l 显示 .xz 文件的基本信息。基本信息包括压缩率、数据完整性验证方式等。

pandas.png  pandas.png.xz[root@master test03]# xz -l pandas.png.xz Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename    1       1     29.7 KiB     29.9 KiB  0.995  CRC64   pandas.png.xz[root@master test03]# 

使用参数 -0, -1, -2, … -6, … -9 设定压缩率。xz 命令的默认为 6

[root@master test03]# lspandas.png[root@master test03]# xz -8 pandas.png [root@master test03]# xz -l pandas.png.xz Strms  Blocks   Compressed Uncompressed  Ratio  Check   Filename    1       1     29.7 KiB     29.9 KiB  0.995  CRC64   pandas.png.xz[root@master test03]#

使用参数 -H 显示 xz 命令所有 options. 参数 -H 比使用参数 --help 显示的内容更详细。

[root@master test03]# xz -H | moreUsage: xz [OPTION]... [FILE]...Compress or decompress FILEs in the .xz format.Mandatory arguments to long options are mandatory for short options too. Operation mode:  -z, --compress      force compression  -d, --decompress, --uncompress                      force decompression  -t, --test          test compressed file integrity  -l, --list          list information about .xz files Operation modifiers:  -k, --keep          keep (don't delete) input files  -f, --force         force overwrite of output file and (de)compress links  -c, --stdout, --to-stdout                      write to standard output and don't delete input files      --single-stream decompress only the first stream, and silently                      ignore possible remaining input data      --no-sparse     do not create sparse files when decompressing  -S, --suffix=.SUF   use the suffix `.SUF' on compressed files      --files[=FILE]  read filenames to process from FILE; if FILE is                      omitted, filenames are read from the standard input;                      filenames must be terminated with the newline character      --files0[=FILE] like --files but use the null character as terminator Basic file format and compression options:--More--
01de874930028f67c75ccba803850e72.png

往期精彩回顾

c1b70ebe2430f337ed92d4591bcae459.png

每天一条Linux命令(19) gzip (压缩或解压文件)

每天一条Linux命令(18) tar (打包备份)

每天一条Linux命令(17) grep (文本处理三剑客)

每天一条Linux命令(16) mkdir (超详细)

每天一条Linux命令(15) tree (超详细)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值