Skip to content

Instantly share code, notes, and snippets.

@monodot
Created January 20, 2023 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monodot/1b8967057990dddff34495b86d2dd50e to your computer and use it in GitHub Desktop.
Save monodot/1b8967057990dddff34495b86d2dd50e to your computer and use it in GitHub Desktop.
Templatey
#!/bin/sh
# cat <<EOF | ./subst.sh zzzlucy
# name=Lucy
# weather="Good, how about you?!"
# family=Smith
# EOF
set -a
sourceDir="example-files"
targetDir="target"
dir=$1
input=${2:-/dev/stdin}
while read line
do
varslist="$varslist\$$(echo $line | cut -d= -f1)"
export "$line"
done < $input
mkdir -p $targetDir/$dir
envsubst "$varslist" < $sourceDir/demo.txt > $targetDir/$dir/demo.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment