Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Hoe to extract only one file from war file linux / ansible

I am working on a shell command for Ansible in Linux, I have a .war file, and I need only tasks.properties file from it. I tried the below, but it extracts the parent directory folder WEB-INF, so i get WEB-INF/sub/test.properties extracted, when I just need the test.properties outside

unzip test.war "*test.properties*" 

I also tried

jar xf test.war test.properties

This also extracted the main folder, and WEB-INF/sub/test.properties.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I ls , I just want test.properties to appear in the location where I am running this, any suggestions on how to do that ? I am very new to linux / ansible , any help is appreciated

>Solution :

The -j flag is exactly what you need:

unzip -j test.war "*test.properties*" 

From the docs:

-j

junk paths. The archive’s directory structure is not recreated; all
files are deposited in the extraction directory (by default, the
current one).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading