勵志

勵志人生知識庫

unzip用法

unzip」是一個用於解壓ZIP檔案的命令行工具,支持多種選項以適應不同的解壓需求。其具體使用方式如下:

解壓檔案到當前目錄。直接使用「unzip example.zip」即可將example.zip解壓到當前目錄。

解壓檔案到指定目錄。使用「unzip example.zip -d /path/to/directory」將example.zip解壓到指定目錄/path/to/directory。

列出壓縮檔案中的檔案列表。使用「unzip -l example.zip」可以查看example.zip中的檔案列表,而不解壓檔案。

安靜模式。使用「unzip -q example.zip」可以靜默解壓過程,不顯示任何信息。

覆蓋已存在的檔案。使用「unzip -o example.zip」可以設定unzip在解壓時自動覆蓋已存在的檔案。

解壓而不覆蓋已存在的檔案。使用「unzip -n example.zip」可以防止unzip覆蓋已存在的檔案。

遞歸解壓子目錄。使用「unzip -r example.zip」可以遞歸解壓ZIP檔案中的子目錄。

測試壓縮檔案的完整性。使用「unzip -t example.zip」可以測試example.zip的完整性。

只解壓新的或更新的檔案。使用「unzip -u example.zip」可以只解壓那些比源檔案新的檔案。

解壓指定檔案。使用「unzip example.zip -x file1 file2」可以指定不解壓file1和file2這兩個檔案。

此外,「unzip」還支持其他選項,如「-p」將解壓的檔案輸出到標準輸出而不用解壓到磁碟,「-c」將解壓結果輸出到螢幕並進行適當轉換,「-f」更新現有檔案等。