Skip to content

Instantly share code, notes, and snippets.

@yakovkhalinsky
Created April 17, 2018 06:16
Show Gist options
  • Select an option

  • Save yakovkhalinsky/5acdfcf03d1226298c88048886e96501 to your computer and use it in GitHub Desktop.

Select an option

Save yakovkhalinsky/5acdfcf03d1226298c88048886e96501 to your computer and use it in GitHub Desktop.
#! /bin/bash
### USAGE
# example:
# package-json.sh version // current directory
# package-json.sh version /path/to/package/json
FIELD=$1
PACKAGE_PATH=${2-.}
CAT="cat $PACKAGE_PATH/package.json"
VALUE=$($CAT \
| grep $FIELD \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $VALUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment