Skip to content

Instantly share code, notes, and snippets.

@chklauser
Last active November 9, 2015 16:10
Show Gist options
  • Save chklauser/9dfbb8a3a86474e645e7 to your computer and use it in GitHub Desktop.
Save chklauser/9dfbb8a3a86474e645e7 to your computer and use it in GitHub Desktop.
Poor man's bash template
_fill_in() {
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : "\${$1}"/eg' "${1}"
}
# usage
export MY_VAR=15
_fill_in "my_file.tmpl" > "my_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment