I need to be able to read the contents of a file (say MANIFEST) within a jar file.
Currently I do this by extracting the contents of the file and then listing it
${JAVA_HOME}/bin/jar xvf SOME_WAR_FILE.war META-INF/MANIFEST.MF
cat META-INF/MANIFEST.MF
Is it possible to do this using a one liner, without extracting the contents ?
Is this what you are looking for?
unzip -qc SOME_WAR_FILE.war META-INF/MANIFEST.MF
See the previous answer here.
What about this?
unzip -p your.jar META-INF/MANIFEST.MF | cat
the -p
option says:
extract files to pipe, no messages
That | cat
isn't really necessary. It'll print to standard out without it.
A jar or war file is just a standard zip compressed archive, so you can use standard unzip with the -c
option to direct it to stdout
$ file your.jar
your.jar: Zip archive data, at least v1.0 to extract
$ unzip -c your.jar META-INF/MANIFEST.MF
file contents
file contents