I am trying to view the content of a file ( in linux )that is inside a .war file without having to extract the war file. For example inside the war file i am trying to see the content of a file called aa.txt and which is under /path/here/ inside the war file.
Asked
Active
Viewed 4,110 times
1
-
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), etc. – jww Jul 16 '19 at 14:19
1 Answers
4
jar
has x
option for that:
$ jar -help 2>&1 | grep extract
-x extract named (or all) files from archive
Let's try it:
$ jar tvf target/my.war | grep test-data
1811 Tue Jun 21 19:34:50 CEST 2016 WEB-INF/classes/test/spring/test-data.properties
$ jar xvf target/my.war WEB-INF/classes/test/spring/test-data.properties
inflated: WEB-INF/classes/test/spring/test-data.properties
$ ls -l WEB-INF/classes/test/spring/test-data.properties
-rw-rw-r--. 1 coder coder 1811 Jun 21 19:34 WEB-INF/classes/test/spring/test-data.properties

Slava Semushin
- 14,904
- 7
- 53
- 69