How to read MANIFEST.MF file from JAR using Bash











up vote
71
down vote

favorite
21












I need to read MANIFEST.MF maven manifest file from "some.jar" using bash










share|improve this question


















  • 3




    jar files are just zip files.
    – Graham Clark
    Aug 15 '11 at 14:28















up vote
71
down vote

favorite
21












I need to read MANIFEST.MF maven manifest file from "some.jar" using bash










share|improve this question


















  • 3




    jar files are just zip files.
    – Graham Clark
    Aug 15 '11 at 14:28













up vote
71
down vote

favorite
21









up vote
71
down vote

favorite
21






21





I need to read MANIFEST.MF maven manifest file from "some.jar" using bash










share|improve this question













I need to read MANIFEST.MF maven manifest file from "some.jar" using bash







bash jar manifest.mf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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














  • 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












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).







share|improve this answer

















  • 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


















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.






share|improve this answer




























    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






    share|improve this answer




























      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






      share|improve this answer




























        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.






        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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

























          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).







          share|improve this answer

















          • 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















          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).







          share|improve this answer

















          • 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













          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).







          share|improve this answer












          $ 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).








          share|improve this answer












          share|improve this answer



          share|improve this answer










          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














          • 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












          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.






          share|improve this answer

























            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.






            share|improve this answer























              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.






              share|improve this answer












              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.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 15 '11 at 14:33









              Bobby Powers

              1,9651515




              1,9651515






















                  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






                  share|improve this answer

























                    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






                    share|improve this answer























                      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






                      share|improve this answer












                      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







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 15 '11 at 14:33









                      Zsolt Botykai

                      38k107196




                      38k107196






















                          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






                          share|improve this answer

























                            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






                            share|improve this answer























                              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






                              share|improve this answer












                              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







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jun 26 '15 at 22:18









                              Justin Clayton

                              111




                              111






















                                  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.






                                  share|improve this answer



























                                    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.






                                    share|improve this answer

























                                      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.






                                      share|improve this answer














                                      $ 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.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Mar 1 '16 at 12:42

























                                      answered Jun 9 '15 at 8:56









                                      rlovtang

                                      4,31922430




                                      4,31922430






























                                          draft saved

                                          draft discarded




















































                                          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.




                                          draft saved


                                          draft discarded














                                          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





















































                                          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







                                          Popular posts from this blog

                                          Xamarin.iOS Cant Deploy on Iphone

                                          Glorious Revolution

                                          Dulmage-Mendelsohn matrix decomposition in Python