Over a million developers have joined DZone.

Viewing the Contents of an Archive

· DevOps Zone

The DevOps Zone is brought to you in partnership with Sonatype Nexus. The Nexus Suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

Everyone now and then I want to check the contents of an archive without unpacking it, and I tend to use unzip to do so:

$ unzip -l batch-import-jar-with-dependencies.jar | tail -n 10 
     1645  02-17-13 01:03   org/neo4j/batchimport/StdOutReport.class
     3089  02-17-13 01:03   org/neo4j/batchimport/structs/NodeStruct.class
     1244  02-17-13 01:03   org/neo4j/batchimport/structs/Property.class
     1732  02-17-13 01:03   org/neo4j/batchimport/structs/PropertyHolder.class
     1635  02-17-13 01:03   org/neo4j/batchimport/structs/Relationship.class
      905  02-17-13 01:03   org/neo4j/batchimport/utils/Chunker.class
     1884  02-17-13 01:03   org/neo4j/batchimport/utils/Params.class
     4445  02-17-13 01:03   org/neo4j/batchimport/Utils.class
 --------                   -------
 49947859                   16447 files

It does the job although it does print out some information that we’re not really interested in so I was intrigued to see that Alistair used zipinfo when he wanted to achieve a similar thing:

$ zipinfo -1 batch-import-jar-with-dependencies.jar | tail -n 10
org/neo4j/batchimport/ParallelImporter.class
org/neo4j/batchimport/Report.class
org/neo4j/batchimport/StdOutReport.class
org/neo4j/batchimport/structs/NodeStruct.class
org/neo4j/batchimport/structs/Property.class
org/neo4j/batchimport/structs/PropertyHolder.class
org/neo4j/batchimport/structs/Relationship.class
org/neo4j/batchimport/utils/Chunker.class
org/neo4j/batchimport/utils/Params.class
org/neo4j/batchimport/Utils.class

From a bit of man page reading it sounds like zipinfo is unzip, but with different flags that give an output that’s a cross between unzip and ls:

The format is a cross between
Unix “ls -l” and “unzip -v” output. See DETAILED DESCRIPTION below. Note that zipinfo is the same program as unzip (under Unix, a link to it); on some systems,
however, zipinfo support may have been omitted when unzip was compiled.

As long as I remember I’ll be using zipinfo from now on!

The DevOps Zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

Topics:

Published at DZone with permission of Mark Needham, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}