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

每天一条Linux命令(20) xz (文件解压缩)相信大家一定对命令 xz 感到陌生 我也是 在第一次遇到这种格式的文件压缩包时 我竟不知如何去解压怎么办 怎么办 此时鼠标已不受控制 默默的移向了 google

大家好,欢迎来到IT知识分享网。

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


相信大家一定对命令 xz 感到陌生,我也是,在第一次遇到这种格式的文件压缩包时,每天一条Linux命令(20) xz (文件解压缩)我竟不知如何去解压

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

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

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

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

 

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/153478.html

(0)
上一篇 2025-03-03 19:15
下一篇 2025-03-03 19:25

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信