How do I search the content of 7-Zip archives (.7z)?

10

4

I am looking for a way to search the content of files inside of a 7-Zip archive (.7z) without having to unpack the archive. I have many 7-Zip archives with code inside them and I'd like to search them.

Is there a way to do that?

Martin

Posted 2011-08-23T05:10:58.273

Reputation: 435

There are a few utilities that do this very well. See newest answers. – gravidThoughts – 2016-09-12T18:43:58.477

What Operating System? – Darth Android – 2011-08-23T05:12:35.350

ditto. Though from what i can tell, there's no working way to mount a 7z archive in filesystem in linux, which would allow him to use the usual *nix file tools to search. – Journeyman Geek – 2011-08-23T06:05:13.810

@Martin: search for which criteria? name? bytes inside the files stored in the .7z? – akira – 2011-08-23T06:12:42.490

OS: Windows; Criteria example: "my string" – Martin – 2011-08-23T12:59:33.397

Answers

10

On Windows, use a command prompt:

cd C:\Program Files\7-Zip
7z

To search for a specific file, e.g. namefile:

7z l compressed.tar namefile -r

Video tutorial: Search files with 7-Zip

flaviofire

Posted 2011-08-23T05:10:58.273

Reputation: 116

9Yes, this works, and it is quite fast, especially if there is not a lot of matches. But the folder where 7z.exe lives must be in PATH, for example C:\Program Files\7-Zip. However, it does *not* search the *content* of files, only the file names and thus does not answer the question. – Peter Mortensen – 2015-03-19T10:01:44.100

4

WinRAR can do it. However, let's face that fact it involves unpacking it, even though WinRAR does it seamlessly.

WinRAR, searching an archive

user477799

Posted 2011-08-23T05:10:58.273

Reputation:

2

dnGrep is an excellent Windows grep implementation that has an archive file plugin that works with all archive formats. You can use Regex, Xpath, Text, or phonetic for your search.

gravidThoughts

Posted 2011-08-23T05:10:58.273

Reputation: 163

Just installed this. When I try to run it, I see dnGREP.exe in the process list, but no GUI appears. Tried killing it and relaunching it to no effect. Will have to try something else. – pacoverflow – 2017-02-02T19:18:47.660

2

As others have said, no there is no way. To examine the contents of a file, it needs to be unpacked (regardless of if the files are compressed solid or not or if they are encrypted or not). The only way that you can avoid having to decompress the files is if they are added with the store method (ie, not compressed at all, just globbed together).

Synetech

Posted 2011-08-23T05:10:58.273

Reputation: 63 242

2

Try out SearchInZipFiles: It is a simple Open Source Tool for Windows located on Sourceforge:

http://sourceforge.net/projects/searchinzipfiles/?source=directory

kking

Posted 2011-08-23T05:10:58.273

Reputation: 21

1

If you're on Linux with 7-Zip installed:

find . -iname *7z -exec 7zr -l \{\} \; | grep "filename.cpp"

Darth Android

Posted 2011-08-23T05:10:58.273

Reputation: 35 133

1That is still unpacking them. Although it is not possible to do what the OP wants without unpacking them, so... – EBGreen – 2011-08-23T05:23:52.920

I'm in agreement with EBGreen. You gotta unpack them, unless you are ok with incomplete results. – surfasb – 2011-08-23T05:38:31.903

1Doesn’t that command just search for filenames? Martin wants to search *inside the files themselves*, not just their names. – Synetech – 2011-08-23T05:43:42.277