zipinfo lists all entries in the archive line by line and summarizes all the information in the archive.
Using zipinfo
The basic syntax to use the command is:
Assuming you have a zip archive file, you need to pass its name to the command and you will see all the information. For our example, let’s create a zip archive containing different files and directories using the zip command.
We’ve created a zip archive, parentdir.zip, that we will use.
Zipinfo – Basic Usage
1. List Archive Information
To list the contents and information of the zip archive, use the command:
The output displays the permissions of the contents inside the archive, the size, and the total entries. Besides, this is the default” ls -l” format for Unix and it can also get invoked using the -s flag.
In the output, the first field represents the file permissions of each file. The next field, in our case, 3.0, represents the version of the zip. The last three fields are the file’s name and the date and time of modification.
2. Display Zip Size
To see the size of your zip archive files, use the -h flag.
In our case, the zip file is 880 bytes and we only have 6 entries contained in it.
3. List Only Filenames
You can display the names of the files inside the zip file, excluding all other details, such as comments, trailers, and headers. Use the -1 flag as shown.
Only the filenames get displayed.
4. List in Verbose
The -v flag will list the zip file information in a multipage format and highlight the details of each file in the archive.
You can note that the information represents each of the archive contents and all its information such as comments, size, permissions, compression size, length of the file, and more. If you want to get all the details of the archive zip, the -v flag got your back.
5. List Total Files
The quickest way to list the total number of the files in a zip archive (the compressed and uncompressed total sizes, and the compression factor) is to use the -t flag. However, it’s worth noting that the compressed total size is exclusive of the additional header bytes for every encrypted entry.
To list total files:
6. Display Date and Time
You can use the -T flag to print in the form of yymmdd.hhmmss if you prefer using the sortable decimal format for the dates,
The output will be:
It’s almost like the standard format except for the decimal format.
7. Include Archive Comment
If the zip archive has any comments, you can include them in the output by adding the -z flag.
8. Dealing with a Single File in the Archive
Having seen the contents of your archive, you can choose to list a single file’s information. To do so, you need to specify the name of your target file.
For instance, in our case, we can print the details of file5.txt using the command:
In the output below, we now have details of file5.txt alone.
You can also combine different options while explicitly specifying which file within the archive to use.
Let’s take an example of getting the information of a specific file. The command will be:
The output will only give the details of file5.txt, as shown.
9. See Most Recently Modified
The -T flag lets you display the date and time associated with the files in a symbolic format. If you combine it with a sorting utility, you can view the recently modified files starting with the most recent.
Use the command:
The -nr sorts the date numerically in reverse. In our case, we have our file5.txt as the most recently modified file.
Conclusion
There is much functionality associated with zipinfo, and what we’ve covered today doesn’t limit its power. Anytime you need to display the contents of a zip archive, use the zipinfo Linux command. Furthermore, zipinfo –v will open the help page for you to navigate your way around.