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

Unzipping a file without saving its contents

I am unzipping the mysql-api.jpi file with the following command:

unzip mysql-api.jpi

Here is the output I get:

Archive:  mysql-api.jpi
creating: META-INF/
inflating: META-INF/MANIFEST.MF    
creating: WEB-INF/
creating: WEB-INF/lib/
creating: META-INF/maven/
creating: META-INF/maven/io.jenkins.plugins/
creating: META-INF/maven/io.jenkins.plugins/mysql-api/
inflating: WEB-INF/lib/mysql-connector-j-8.4.0.jar  
inflating: WEB-INF/lib/mysql-api.jar  
inflating: WEB-INF/lib/protobuf-java-3.25.1.jar  
inflating: WEB-INF/licenses.xml    
inflating: META-INF/maven/io.jenkins.plugins/mysql-api/pom.xml  
inflating: META-INF/maven/io.jenkins.plugins/mysql-api/pom.properties

And then I need to copy one of the files to classpath:

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

cp WEB-INF/lib/mysql-connector-j-8.4.0.jar /var/lib/jenkins/war/WEB-INF/lib

Is there a way to directly unzip and copy without saving the files generated from unzipping?

>Solution :

Yes. Use the -p option to pipe the output to stdout. Then you can:

unzip -p mysql-api.jpi WEB-INF/lib/mysql-connector-j-8.4.0.jar > /var/lib/jenkins/war/WEB-INF/lib/mysql-connector-j-8.4.0.jar

That would be useful if you want to pipe the extracted data through some other processing. Since you are simply copying the file, which is in fact saving it, a more direct approach would be to specify the directory to extract to:

unzip -d /var/lib/jenkins/war/ mysql-api.jpi WEB-INF/lib/mysql-connector-j-8.4.0.jar
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