zot24
8/21/2015 - 3:47 PM

Extract version from package.json (NPM) using bash / shell

Extract version from package.json (NPM) using bash / shell

# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
  | grep version \
  | head -1 \
  | awk -F: '{ print $2 }' \
  | sed 's/[",]//g')

echo $PACKAGE_VERSION