How to read MANIFEST.MF file from JAR using Bash
up vote
71
down vote
favorite
I need to read MANIFEST.MF maven manifest file from "some.jar" using bash
bash jar manifest.mf
add a comment |
up vote
71
down vote
favorite
I need to read MANIFEST.MF maven manifest file from "some.jar" using bash
bash jar manifest.mf
3
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28
add a comment |
up vote
71
down vote
favorite
up vote
71
down vote
favorite
I need to read MANIFEST.MF maven manifest file from "some.jar" using bash
bash jar manifest.mf
I need to read MANIFEST.MF maven manifest file from "some.jar" using bash
bash jar manifest.mf
bash jar manifest.mf
asked Aug 15 '11 at 14:23
Roman
388145
388145
3
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28
add a comment |
3
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28
3
3
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28
add a comment |
5 Answers
5
active
oldest
votes
up vote
126
down vote
accepted
$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF
-q
will suppress verbose output from the unzip program
-c
will extract to stdout
Example:
$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Package: org.apache.commons.lang
Extension-Name: commons-lang
Specification-Version: 2.4
Specification-Vendor: Apache Software Foundation
Specification-Title: Commons Lang
Implementation-Version: 2.4
Implementation-Vendor: Apache Software Foundation
Implementation-Title: Commons Lang
Implementation-Vendor-Id: org.apache
X-Compile-Source-JDK: 1.3
X-Compile-Target-JDK: 1.2
Alternatively you can use -p
instead of -q -c
.
-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
add a comment |
up vote
16
down vote
use unzip
:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF
that will quietly (-q
) read the path META-INF/MANIFEST.MF from the jarfile (which is compressed using the zip format) to stdout (-c
). You can then pipe the output to other command to answer questions like 'what is the main class for this jar:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF | grep 'Main-Class' | cut -d ':' -f 2
(this removes all lines which don't contain the string Main-Class
, then splits the line at :
, keeping only the second field, the class name). Of course, either define $JARFILE_PATH
appropriately or replace $JARFILE_PATH
with the path to a jarfile you're interested in.
add a comment |
up vote
4
down vote
Depending on your distribution, install the unzip
package. Then simply issue
unzip -p YOUR_FILE.jar META-INF/MANIFEST.MF
This will dump the contents to STDOUT.
HTH
add a comment |
up vote
1
down vote
Others have been posting about using unzip -p and piping to grep or awk or whatever you need. While that works for most cases, it's worth noting that because of the 72 characters-per-line limit of MANIFEST.MF, you may be grepping for keys whose values are split across multiple lines and will therefore be very difficult to parse. I'd love to see a CLI tool that can actually pull a rendered value out of the file.
http://delaltctrl.blogspot.com/2009/11/manifestmf-apparently-you-are-just.html
add a comment |
up vote
0
down vote
$ tar xfO some.jar META-INF/MANIFEST.MF
x
extracts and O
redirects to stdout.
Note: Seem to work only in bsdtar, not GNU tar.
add a comment |
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
126
down vote
accepted
$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF
-q
will suppress verbose output from the unzip program
-c
will extract to stdout
Example:
$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Package: org.apache.commons.lang
Extension-Name: commons-lang
Specification-Version: 2.4
Specification-Vendor: Apache Software Foundation
Specification-Title: Commons Lang
Implementation-Version: 2.4
Implementation-Vendor: Apache Software Foundation
Implementation-Title: Commons Lang
Implementation-Vendor-Id: org.apache
X-Compile-Source-JDK: 1.3
X-Compile-Target-JDK: 1.2
Alternatively you can use -p
instead of -q -c
.
-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
add a comment |
up vote
126
down vote
accepted
$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF
-q
will suppress verbose output from the unzip program
-c
will extract to stdout
Example:
$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Package: org.apache.commons.lang
Extension-Name: commons-lang
Specification-Version: 2.4
Specification-Vendor: Apache Software Foundation
Specification-Title: Commons Lang
Implementation-Version: 2.4
Implementation-Vendor: Apache Software Foundation
Implementation-Title: Commons Lang
Implementation-Vendor-Id: org.apache
X-Compile-Source-JDK: 1.3
X-Compile-Target-JDK: 1.2
Alternatively you can use -p
instead of -q -c
.
-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
add a comment |
up vote
126
down vote
accepted
up vote
126
down vote
accepted
$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF
-q
will suppress verbose output from the unzip program
-c
will extract to stdout
Example:
$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Package: org.apache.commons.lang
Extension-Name: commons-lang
Specification-Version: 2.4
Specification-Vendor: Apache Software Foundation
Specification-Title: Commons Lang
Implementation-Version: 2.4
Implementation-Vendor: Apache Software Foundation
Implementation-Title: Commons Lang
Implementation-Vendor-Id: org.apache
X-Compile-Source-JDK: 1.3
X-Compile-Target-JDK: 1.2
Alternatively you can use -p
instead of -q -c
.
-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).
$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF
-q
will suppress verbose output from the unzip program
-c
will extract to stdout
Example:
$ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Package: org.apache.commons.lang
Extension-Name: commons-lang
Specification-Version: 2.4
Specification-Vendor: Apache Software Foundation
Specification-Title: Commons Lang
Implementation-Version: 2.4
Implementation-Vendor: Apache Software Foundation
Implementation-Title: Commons Lang
Implementation-Vendor-Id: org.apache
X-Compile-Source-JDK: 1.3
X-Compile-Target-JDK: 1.2
Alternatively you can use -p
instead of -q -c
.
-p extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).
answered Aug 15 '11 at 14:33
miku
127k32244271
127k32244271
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
add a comment |
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
1
1
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
I know this thread is old, but for whom it may concern: As from the manual, extracting using -p or -c will print output in binary form. If you need to parse this output somehow (for example to associative array), you should force text representation with -aa argument, to have it correct.
– tcigler
Sep 27 '16 at 13:36
add a comment |
up vote
16
down vote
use unzip
:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF
that will quietly (-q
) read the path META-INF/MANIFEST.MF from the jarfile (which is compressed using the zip format) to stdout (-c
). You can then pipe the output to other command to answer questions like 'what is the main class for this jar:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF | grep 'Main-Class' | cut -d ':' -f 2
(this removes all lines which don't contain the string Main-Class
, then splits the line at :
, keeping only the second field, the class name). Of course, either define $JARFILE_PATH
appropriately or replace $JARFILE_PATH
with the path to a jarfile you're interested in.
add a comment |
up vote
16
down vote
use unzip
:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF
that will quietly (-q
) read the path META-INF/MANIFEST.MF from the jarfile (which is compressed using the zip format) to stdout (-c
). You can then pipe the output to other command to answer questions like 'what is the main class for this jar:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF | grep 'Main-Class' | cut -d ':' -f 2
(this removes all lines which don't contain the string Main-Class
, then splits the line at :
, keeping only the second field, the class name). Of course, either define $JARFILE_PATH
appropriately or replace $JARFILE_PATH
with the path to a jarfile you're interested in.
add a comment |
up vote
16
down vote
up vote
16
down vote
use unzip
:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF
that will quietly (-q
) read the path META-INF/MANIFEST.MF from the jarfile (which is compressed using the zip format) to stdout (-c
). You can then pipe the output to other command to answer questions like 'what is the main class for this jar:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF | grep 'Main-Class' | cut -d ':' -f 2
(this removes all lines which don't contain the string Main-Class
, then splits the line at :
, keeping only the second field, the class name). Of course, either define $JARFILE_PATH
appropriately or replace $JARFILE_PATH
with the path to a jarfile you're interested in.
use unzip
:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF
that will quietly (-q
) read the path META-INF/MANIFEST.MF from the jarfile (which is compressed using the zip format) to stdout (-c
). You can then pipe the output to other command to answer questions like 'what is the main class for this jar:
$ unzip -q -c $JARFILE_PATH META-INF/MANIFEST.MF | grep 'Main-Class' | cut -d ':' -f 2
(this removes all lines which don't contain the string Main-Class
, then splits the line at :
, keeping only the second field, the class name). Of course, either define $JARFILE_PATH
appropriately or replace $JARFILE_PATH
with the path to a jarfile you're interested in.
answered Aug 15 '11 at 14:33
Bobby Powers
1,9651515
1,9651515
add a comment |
add a comment |
up vote
4
down vote
Depending on your distribution, install the unzip
package. Then simply issue
unzip -p YOUR_FILE.jar META-INF/MANIFEST.MF
This will dump the contents to STDOUT.
HTH
add a comment |
up vote
4
down vote
Depending on your distribution, install the unzip
package. Then simply issue
unzip -p YOUR_FILE.jar META-INF/MANIFEST.MF
This will dump the contents to STDOUT.
HTH
add a comment |
up vote
4
down vote
up vote
4
down vote
Depending on your distribution, install the unzip
package. Then simply issue
unzip -p YOUR_FILE.jar META-INF/MANIFEST.MF
This will dump the contents to STDOUT.
HTH
Depending on your distribution, install the unzip
package. Then simply issue
unzip -p YOUR_FILE.jar META-INF/MANIFEST.MF
This will dump the contents to STDOUT.
HTH
answered Aug 15 '11 at 14:33
Zsolt Botykai
38k107196
38k107196
add a comment |
add a comment |
up vote
1
down vote
Others have been posting about using unzip -p and piping to grep or awk or whatever you need. While that works for most cases, it's worth noting that because of the 72 characters-per-line limit of MANIFEST.MF, you may be grepping for keys whose values are split across multiple lines and will therefore be very difficult to parse. I'd love to see a CLI tool that can actually pull a rendered value out of the file.
http://delaltctrl.blogspot.com/2009/11/manifestmf-apparently-you-are-just.html
add a comment |
up vote
1
down vote
Others have been posting about using unzip -p and piping to grep or awk or whatever you need. While that works for most cases, it's worth noting that because of the 72 characters-per-line limit of MANIFEST.MF, you may be grepping for keys whose values are split across multiple lines and will therefore be very difficult to parse. I'd love to see a CLI tool that can actually pull a rendered value out of the file.
http://delaltctrl.blogspot.com/2009/11/manifestmf-apparently-you-are-just.html
add a comment |
up vote
1
down vote
up vote
1
down vote
Others have been posting about using unzip -p and piping to grep or awk or whatever you need. While that works for most cases, it's worth noting that because of the 72 characters-per-line limit of MANIFEST.MF, you may be grepping for keys whose values are split across multiple lines and will therefore be very difficult to parse. I'd love to see a CLI tool that can actually pull a rendered value out of the file.
http://delaltctrl.blogspot.com/2009/11/manifestmf-apparently-you-are-just.html
Others have been posting about using unzip -p and piping to grep or awk or whatever you need. While that works for most cases, it's worth noting that because of the 72 characters-per-line limit of MANIFEST.MF, you may be grepping for keys whose values are split across multiple lines and will therefore be very difficult to parse. I'd love to see a CLI tool that can actually pull a rendered value out of the file.
http://delaltctrl.blogspot.com/2009/11/manifestmf-apparently-you-are-just.html
answered Jun 26 '15 at 22:18
Justin Clayton
111
111
add a comment |
add a comment |
up vote
0
down vote
$ tar xfO some.jar META-INF/MANIFEST.MF
x
extracts and O
redirects to stdout.
Note: Seem to work only in bsdtar, not GNU tar.
add a comment |
up vote
0
down vote
$ tar xfO some.jar META-INF/MANIFEST.MF
x
extracts and O
redirects to stdout.
Note: Seem to work only in bsdtar, not GNU tar.
add a comment |
up vote
0
down vote
up vote
0
down vote
$ tar xfO some.jar META-INF/MANIFEST.MF
x
extracts and O
redirects to stdout.
Note: Seem to work only in bsdtar, not GNU tar.
$ tar xfO some.jar META-INF/MANIFEST.MF
x
extracts and O
redirects to stdout.
Note: Seem to work only in bsdtar, not GNU tar.
edited Mar 1 '16 at 12:42
answered Jun 9 '15 at 8:56
rlovtang
4,31922430
4,31922430
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f7066063%2fhow-to-read-manifest-mf-file-from-jar-using-bash%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
jar files are just zip files.
– Graham Clark
Aug 15 '11 at 14:28