7-Zip 命令列下解壓縮特定檔案
在 command line 下解壓縮 .7z 檔案內某一個特定檔案。
先用列出壓縮檔內的檔案清單(以 photos.7z 為例)。
ghill@ghill:~$ 7z l photos.7z
--
Path = photos.7z
Type = 7z
Physical Size = 2934737
Headers Size = 279
Method = LZMA2:3m
Solid = +
Blocks = 1
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2022-02-21 14:07:35 D.... 0 0 photos
2022-02-21 14:07:35 ....A 947811 2934458 photos/1.png
2022-02-21 14:07:35 ....A 883797 photos/2.png
2022-02-21 14:07:35 ....A 718844 photos/3.png
2022-02-21 14:07:35 ....A 39056 photos/cat.png
2022-02-21 14:07:35 ....A 87253 photos/live.png
2022-02-21 14:07:35 ....A 33762 photos/live_120.png
2022-02-21 14:07:35 ....A 123127 photos/live_240.png
2022-02-21 14:07:35 ....A 107068 photos/ss.png
------------------- ----- ------------ ------------ ------------------------
2022-02-21 14:07:35 2940718 2934458 8 files, 1 folders
假設我只想要解壓縮 cat.png
就好,我可以用下列指令解壓縮:
ghill@ghill:~$ 7z e photos.7z -o./ cat.png -r
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Celeron(R) CPU E3300 @ 2.50GHz (1067A),ASM)
Scanning the drive for archives:
1 file, 2934737 bytes (2866 KiB)
Extracting archive: photos.7z
--
Path = photos.7z
Type = 7z
Physical Size = 2934737
Headers Size = 279
Method = LZMA2:3m
Solid = +
Blocks = 1
Everything is Ok
Files: 4
Size: 2589508
Compressed: 2934737
7z
用到的參數簡介:
l
: List contents of archive.
e
: Extract files from archive (without using directory names).
-o{Directory}
: Set Output directory.
-r
: Recurse subdirectories (CAUTION: this flag does not do what you think, avoid using it).
-o
跟後面的路徑要連在一起,不能有空格。