List Archive Contents with 7-Zip CLI

This guide explains how to view the contents of an archive file using the 7-Zip command-line interface (CLI) without extracting it. By using the built-in listing command, you can inspect file names, compressed sizes, uncompressed sizes, modification dates, and folder structures directly from your terminal.

The Basic List Command

The command used to list archive contents without extraction is l (lowercase L).

The basic syntax is:

7z l archive_name.7z

Depending on your installation and operating system, the executable name might be 7z, 7za, or 7zr.

Example

To list the contents of a ZIP file named data.zip:

7z l data.zip

Sample Output

Running this command displays metadata about the archive (type, physical size, headers size) followed by a column-based table:

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2023-10-15 10:20:14 ....A         1024          420  document.txt
2023-10-15 10:22:01 ....A       524288       120450  image.png
------------------- ----- ------------ ------------  ------------------------
2023-10-15 10:22:01             525312       120870  2 files

Useful Options and Switches

1. Show Detailed Technical Information (-slt)

If you need comprehensive details for every file (such as full paths, exact byte counts, CRC checksums, and compression methods), use the -slt switch:

7z l -slt data.zip

This formats the output as key-value pairs, which is particularly useful for shell scripts and automated parsing.

2. Filter Specific Files

You can search for specific file types or filenames within the archive by appending a filter pattern to the command:

7z l data.zip *.txt

This displays only the files matching the .txt extension inside data.zip.

3. Inspect Password-Protected Archives

If an archive encrypts file names (common with .7z archives using header encryption), provide the password using the -p switch to read the table of contents:

7z l -pSecretPassword secure_data.7z