Created
February 18, 2020 12:18
-
-
Save sfgeorge/b08e510c77fd36009d85a5d91743fa24 to your computer and use it in GitHub Desktop.
Simple UNIX templating with the printf command
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
# Create a template | |
echo 'I am just a lowly %s, | |
playing with %s and %s, | |
dancing in a %s and trying not to get %s.' > jolly.template | |
# Evaluate the template | |
printf "$(<jolly.template)" scoundrel sticks 'barbed wire' web caught | |
# Or Evaluate the template and silently set it to a shell variable | |
printf -v output "$(<jolly.template)" scoundrel sticks 'barbed wire' web caught | |
echo "$output" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment