Here Document Template Substitution
Generate a config file from a here document template with variable expansion and command substitution.
Code
#!/usr/bin/env bash
set -euo pipefail
APP_NAME="myapp"
PORT="${1:-8080}"
HOSTNAME=$(hostname)
cat > config.yaml <<EOF
app:
name: ${APP_NAME}
port: ${PORT}
host: ${HOSTNAME}
generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
EOF
cat config.yamlReport a problem with this exampleOpens a pre-filled issue on GitHub.