name="Alice"
# Quoted delimiter: NO expansion (good for embedding scripts or shell snippets)
cat <<'EOF'
Hello $name — this $variable stays literal.
EOF
# Unquoted: full expansion
cat <<EOF
Hello $name — interpolated.
Current dir: $(pwd)
Date: $(date)
EOF
# <<-EOF strips leading tabs (handy when indenting inside if/for)
if true; then
cat <<-'EOF'
Indented heredoc — leading tabs stripped, single quotes prevent expansion.
Useful inside functions / conditional blocks.
EOF
fi
Create a free account and build your private vault. Share publicly whenever you want.