使用 7-Zip 从存档中提取特定文件

Ale*_*eev 8 linux 7z files p7zip

我运行 Linux Live CD,我需要从位于磁盘驱动器上的 wim-archive 中提取特定文件。我知道存档中文件的完整路径:

xubuntu@xubuntu:~$ 7z l winRE.wim | grep -i bootrec.exe
2009-08-28 15:02:29 ....A       299008       134388  Windows/System32/BootRec.exe
Run Code Online (Sandbox Code Playgroud)

我的磁盘空间不足,无法解压整个存档。

如何从存档中提取该特定文件?

我尝试了该-i选项,但这不起作用:

xubuntu@xubuntu:~$ 7z x -i Windows/System32/BootRec.exe winRE.wim 


Error:
Incorrect command line
Run Code Online (Sandbox Code Playgroud)

Ale*_*eev 13

man 7z页面说:

  -i[r[-|0]]{@listfile|!wildcard}
         Include filenames
Run Code Online (Sandbox Code Playgroud)

您需要!在文件名之前明确指定并使用单引号保护开关免受 bash 扩展的影响:7z x '-i!Windows/System32/BootRec.exe' winRE.wim

xubuntu@xubuntu:~$ 7z x '-i!Windows/System32/BootRec.exe' winRE.wim

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: winRE.wim

Extracting  Windows/System32/BootRec.exe

Everything is Ok

Size:       299008
Compressed: 227817568
Run Code Online (Sandbox Code Playgroud)

(您可以通过使用e函数字母来避免保留完整路径:7z e '-i!Windows/System32/BootRec.exe' winRE.wim。)

顺便说一句,如果您不-i使用单引号保护选项或使用双引号保护它,则会出现错误:

xubuntu@xubuntu:~$ 7z x "-i!Windows/System32/BootRec.exe" winRE.wim 
bash: !Windows/System32/BootRec.exe: event not found
Run Code Online (Sandbox Code Playgroud)