tft每日頭條

 > 科技

 > linux下看到文件大小的命令

linux下看到文件大小的命令

科技 更新时间:2025-04-02 12:07:41

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 (打包備份) ,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部
mac

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved