Skip to content

Instantly share code, notes, and snippets.

@pateketrueke
Created May 18, 2018 20:52
Show Gist options
  • Save pateketrueke/7f6354639765c38cb8355237b8b5fcb0 to your computer and use it in GitHub Desktop.
Save pateketrueke/7f6354639765c38cb8355237b8b5fcb0 to your computer and use it in GitHub Desktop.
Extract ENV vars from JSON files
#!/bin/bash
set -eu
echo "$( tr '\n' ' ' < vars.json | jq -r 'keys[] as $k | "export \($k)=\"\(.[$k])\""' )"
# usage:
# ./env.sh > .env
#. source .env
# echo "$SOME_ENV_VALUE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment