How to view the Contents of ZIP or TAR files without extracting in Linux

Configurare noua (How To)

Situatie

Solutie

Working with archives is a common task in Linux, but sometimes, you may not know what the contents of the archive look like. If you want to take a peek at the inside of a ZIP or TAR file without extracting it, there are tools that can help you.

Using unzip to View ZIP Files

To view inside ZIP files, you’ll need the unzip command utility, which might not be included by default. You can install it from your system’s package manager if it isn’t:

unzip -l file

If you want just a raw list of all the files in the archive, you can use zipinfo with the -1 flag to only print filenames:

zipinfo -1 file

This can be useful for bash scripts, or when piped to other commands like less, which can help you search through a large archive. You can also pipe it to a text utility like grep or sed to find matches for certain files:

zipinfo -1 file | grep string

Using tar to View tarballs

TAR archives, also known as tarballs, are another kind of archive format used commonly in Linux. You can also print the contents of these without extracting them, by using the -t flag

tar -tf filename.tar.gz

Like zipinfo, this prints a raw list of all the files, and can be piped to other utilities for processing.

Tip solutie

Permanent

Voteaza

(1 din 1 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?