0

I have a war file on a linux server.
I need to display the contents of a file in the war file. Not just display what is in the war file. I can display the contents of the war file using this command: jar -tvf file1.war

I need to display the contents of the manifest file in this war file. I thought I could use the pipe to add the cat command but it errors with:

No such file or directory

This is the command I tried: jar -tvf file1.war | cat META-INF/MANIFEST.MF

What command I use to view the contents of the manifest file in a war file?

Gloria Santin
  • 2,066
  • 3
  • 51
  • 124
  • Possible duplicate of [Linux command for extracting war file?](https://stackoverflow.com/q/3833578/608639), [One liner for listing contents of file within war file](https://stackoverflow.com/q/23000741/608639), [how to list the contents of a jar file inside a war file](https://stackoverflow.com/q/3238285/608639), [Seeing contents of war file without extracting](https://stackoverflow.com/q/34533367/608639), [How to extract .war files in java? ZIP vs JAR](https://stackoverflow.com/q/7882745), [Extract/See content of a specific file inside a .war file](https://stackoverflow.com/q/37972850), etc. – jww Jul 16 '19 at 14:14
  • Once the war file is extracted, I want to display the contents of a file in the war file. So it requires concatenation of command – Gloria Santin Jul 16 '19 at 20:28
  • Yep, that is covered in the duplicates. – jww Jul 16 '19 at 21:04

2 Answers2

3

I found something that worked for me...

unzip -p file1.war META-INF/MANIFEST.MF

Gloria Santin
  • 2,066
  • 3
  • 51
  • 124
1

You're seeing "no such file or directory" because the cat command can't find your manifest file. This is because the t option of jar only lists the files in the war file and does not extract them. Then, piping the list of files into cat META-INF/MANIFEST.MF causes the error message because the file does not exist because it was never extracted.

Try this, using the x (for extract) option instead:

# extract the MANIFEST.MF file
jar xvf file1.war META-INF/MANIFEST.MF
# cat it to the terminal
cat META-INF/MANIFEST.MF
# if you're sure that you're not deleting something important, then you can execute this to get rid of the META-INF directory:
# rm -rf META-INF
Mark
  • 974
  • 7
  • 10