How can I retrieve the version attribute from the following json file AND use it in a BASH script?..
file package.json
{
"name": "myapp",
"version": "0.0.1"
}
desired script: bpush.sh
#!/bin/bash
gulp bump
git add -A
eval $pkg_ver = getjson('./package.json', 'version')
git commit -a -m "$pkg_ver"
git push origin master
Obviously, the getjson() function is invalid. That is what I'm trying to figure out.
Edit: Final Result
Here's what I used, thanks to the folks below...
#!/bin/sh
pkg_ver=$(jq '.version' package.json)
pkg_ver=${pkg_ver//\"/}
git add -A
git commit -a -m $pkg_ver
git push origin master
pkg_ver=$(tr -cd '[0-9.]' < package.json)?evalhere; just usepkg_ver=$(...), where...will be provided by an acceptable answer.