相信大家一定對命令 xz 感到陌生,我也是,在第一次遇到這種格式的文件壓縮包時,
我竟不知如何去解壓
怎麼辦、怎麼辦,此時鼠标已不受控制,默默的移向了google。
事情經的經過就是這樣,其實事發挺突然的,要不是怕遇到熟人,我必須整兩句,趁現在沒人就來說說這個 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[選項][參數]
主要參數說明:
案例:
壓縮圖片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 (打包備份) ,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!