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

bash zip file with version read from file and used in zip file name

I’m able to zip a bunch of files with zip

$ zip build.zip src/*.js src/assets/icons/*.png *.json
updating: src/addReactionsNav.js (deflated 65%)
updating: manifest.json (deflated 55%)
updating: src/assets/icons/icon_128.png (stored 0%)
updating: src/assets/icons/icon_16.png (stored 0%)
updating: src/assets/icons/icon_256.png (deflated 0%)
updating: src/assets/icons/icon_48.png (stored 0%)

but I would like to automate it so the name of the zip includes the version. Figured out to do this:

$ echo "build_$(cat manifest.json | jq .version).zip" | sed s/\"//g
build_1.1.0.zip

But can’t figure out how to "pipe" the two together.

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

Solution

thanks @cyrus

zip "build_$(jq -r .version manifest.json).zip" src/*.js src/assets/icons/*.png *.json

>Solution :

Replace build.zip with "build_$(cat manifest.json | jq -r .version).zip".

Update:

Replace build.zip with "build_$(jq -r .version manifest.json).zip".

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