Created
January 31, 2024 02:29
-
-
Save mmyoji/43102921449ac2e107b8cb802cc71259 to your computer and use it in GitHub Desktop.
Multiline variables in bash
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
#!/bin/bash | |
function print_multiline() { | |
local text=$(cat <<'EOF' | |
``` | |
# Markdown Text | |
- one | |
- two | |
``` | |
EOF | |
) | |
echo "$text" | |
# `echo $text` doesn't work as you expected | |
} | |
print_multiline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment