Skip to content

Instantly share code, notes, and snippets.

@mmyoji
Created January 31, 2024 02:29
Show Gist options
  • Save mmyoji/43102921449ac2e107b8cb802cc71259 to your computer and use it in GitHub Desktop.
Save mmyoji/43102921449ac2e107b8cb802cc71259 to your computer and use it in GitHub Desktop.
Multiline variables in bash
#!/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