Skip to content

Instantly share code, notes, and snippets.

@Azerothian
Created December 31, 2015 03:48
Show Gist options
  • Save Azerothian/b3500e3d83aa277377a2 to your computer and use it in GitHub Desktop.
Save Azerothian/b3500e3d83aa277377a2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
TEMPLATE_FILE=$1
ENV_PREFIX=$2
env | grep "^$ENV_PREFIX" | while IFS="=" read -r name value; do
printf "s/%s/%q/\n" "${name}" "$value"
done > sed-script.txt
cat sed-script.txt # Optional
sed -f sed-script.txt "$TEMPLATE_FILE"
rm sed-script.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment