I run Linux Live CD and I need to extract a specific file from a wim-archive that is located on a disk drive. I know a full path to the file in the archive:

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

I am short on disk space and do not have a possibility to unpack the whole archive.

How could I extract that specific file from the archive?

I tried the -i option, but that did not work:

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

Incorrect command line

The man 7z page says:

         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
  • You really don't need a wildcard for single file, yet it is useful for extracting all files with pattern. Jul 21 '21 at 8:51
7z e [archive name] -o[direction] [filename] -r

for example:

7z e 'Movies.rar' -o/root/Downloads/ 'Rush.mp4' -r

This command worked for me, I tried it on ubuntu server 16.04.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.