Last active
November 9, 2015 16:10
-
-
Save chklauser/9dfbb8a3a86474e645e7 to your computer and use it in GitHub Desktop.
Poor man's bash template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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