Skip to main content
added 218 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet.

su - db2prd<<EOF
PARMDATE=1111111
echo parmdate
echo \$PARMDATE
EOF

Or better, quote the delimiter (here EOF) to tell your shell not to perform expansions inside the here-document:

su - db2prd<<'EOF'
PARMDATE=1111111
echo parmdate
echo $PARMDATE
EOF

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet.

su - db2prd<<EOF
PARMDATE=1111111
echo parmdate
echo \$PARMDATE
EOF

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet.

su - db2prd<<EOF
PARMDATE=1111111
echo parmdate
echo \$PARMDATE
EOF

Or better, quote the delimiter (here EOF) to tell your shell not to perform expansions inside the here-document:

su - db2prd<<'EOF'
PARMDATE=1111111
echo parmdate
echo $PARMDATE
EOF
Source Link
Kevin
  • 41.7k
  • 17
  • 91
  • 113

Variables are interpreted in a here doc (<<...), so you need to escape the ones you don't want evaluated yet.

su - db2prd<<EOF
PARMDATE=1111111
echo parmdate
echo \$PARMDATE
EOF