Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 使用 tar tvf 與 awk 不解壓直接查看 tar.gz 內部檔案大小與名稱

編輯:關於 Linux

大型壓縮包解壓耗時,僅需查看特定檔案大小。tar tvf 列出清單,配合 awk 擷取欄位即可高效獲取資訊。

基本指令

tar tvf my_file.tar.gz

輸出欄位:權限、用戶/組、大小 (位元組)、日期、檔名。

擷取大小與檔名

tar tvf my_file.tar.gz | awk '{print $3, $6}'

單位換算 (KB/MB/GB)

# GB
tar tvf my_file.tar.gz | awk '{print $3/1024/1024/1024, $6}'
# 輸出: 0.0829872 File_3.txt

大檔案後台處理

nohup tar tvf my_file.tar.gz | awk '{print $3/1024/1024/1024, $6}' > /root/result.txt &

nohup 防止 SSH 斷線中斷任務,結果導向檔案供後續分析。

Copyright © Windows教程網 All Rights Reserved