Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomaswilley/fcf84480a58d71ff7e89c354e5503283 to your computer and use it in GitHub Desktop.
Save thomaswilley/fcf84480a58d71ff7e89c354e5503283 to your computer and use it in GitHub Desktop.
One line template engine that pulls from environment variables. In this example environment variable DIR, contained w/in template infile as "$DIR", will all get replaced by results of `pwd` (current working directory) and the resulting populated template stored in outfile.
DIR=`pwd` awk '{ gsub("\\$DIR",ENVIRON["DIR"]); print $0 }' infile > outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment