Home > other >  bash zip file with version read from file and used in zip file name
bash zip file with version read from file and used in zip file name

Time:01-09

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.

Solution

thanks @cyrus

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

CodePudding user response:

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

Update:

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

  •  Tags:  
  • Related