Extracting a specific file from an archive using 7-Zip
The man 7z
page says:
-i[r[-|0]]{@listfile|!wildcard} Include filenames
You need to explicitly specify !
before the file name and protect the switch from bash expansion with single quotes: 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
(You can avoid keeping the full path by using the e
function letter: 7z e '-i!Windows/System32/BootRec.exe' winRE.wim
.)
BTW, if you do not protect the -i
option with single quotes or protect it with double quotes, you get an error:
xubuntu@xubuntu:~$ 7z x "-i!Windows/System32/BootRec.exe" winRE.wim
bash: !Windows/System32/BootRec.exe: event not found