Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I only know the filename but not its exact location. I would like to extract only that file from the archive. And I need to know its location in the archive.

share|improve this question
unzip -l will provide a listing. Use -h or --help on many/most commands for basic usage – bdowning Apr 3 '14 at 10:43
@bdowning Thanks, and how do I get the path of a specific file from the list? – Patrick Apr 3 '14 at 10:44

3 Answers 3

up vote 3 down vote accepted

unzip accepts wildcards and globs. If you know the filename, then you could simply say:

unzip "**/file_to_extract"

in order to extract the said file.

share|improve this answer
works great, thanks – Patrick Apr 3 '14 at 10:53

As a synthesis of both comment and answer, you could proceed like this:

unzip -l | grep "nameOfile"
#identify the path of the file precisely in your archive if filtering gives you several result and then use 
 unzip ./ham/smoked/nameOfile

This should work

share|improve this answer

Mount the zip archive as a filesystem with fuse-zip. Then you can access files in it using any command you like.

mkdir foo
fuse-zip foo

Then, to copy needle.txt from whichever subdirectory it's in:

find foo -name needle.txt -exec cp -p {} . \;

Or using the shell's recursive globbing (in bash, you need to run shopt -s globstar first; in zsh this works out of the box):

cp -p foo/**/needle.txt .

Unmount the filesystem when you've finished using it.

fusermount -u foo
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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