How import/not import variables when writing Here Document in Bash

import variable:

Var1="linux"

su hans << EOF
echo $Var1
EOF

don’t import variables:

Var1="linux"

su hans << 'EOF'
echo $Var1
EOF

When quoting EOF, the scripts will not import variables.

Leave a Reply

Your email address will not be published. Required fields are marked *