linux下看到文件大小的命令(每天一条Linux命令20)

linux下看到文件大小的命令(每天一条Linux命令20)(1)


相信大家一定对命令 xz 感到陌生,我也是,在第一次遇到这种格式的文件压缩包时,

linux下看到文件大小的命令(每天一条Linux命令20)(2)

我竟不知如何去解压

linux下看到文件大小的命令(每天一条Linux命令20)(3)

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

linux下看到文件大小的命令(每天一条Linux命令20)(4)

事情经的经过就是这样,其实事发挺突然的,要不是怕遇到熟人,我必须整两句,趁现在没人就来说说这个 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]# ls pandas.png [root@master test03]# xz pandas.png [root@master test03]# ls pandas.png.xz [root@master test03]#

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

[root@master test03]# xz -dk pandas.png.xz [root@master test03]# ls pandas.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]# ls pandas.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 | more Usage: 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--

往期精彩回顾

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

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页