Created
October 4, 2019 21:31
-
-
Save thejimnicholson/1c319a04eca180fe5262cab078f77779 to your computer and use it in GitHub Desktop.
Create JSON in bash using heredocs
This file contains 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
#!/usr/bin/env bash | |
var1='value of var1' | |
var2='value of var2' | |
read -r -d '' block <<-END | |
{ | |
"var1": "${var1}", | |
"var2": "${var2}" | |
} | |
END | |
block2=$(cat <<_EOF2_ | |
{ | |
"var1": "${var1}", | |
"var2": "${var2}" | |
} | |
_EOF2_ | |
) | |
echo "$block" | |
echo $block2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment