How to suppress variable substitution in bash heredocs

前端 未结 2 392
遇见更好的自我
遇见更好的自我 2020-12-03 22:46

Is it possible to create a heredoc that does not become subject to variable expansion?

e.g.

cat <<-EOF > somefile.sh
Do not print current va         


        
2条回答
  •  不知归路
    2020-12-03 23:04

    Put backlash before the $ sign

    $ VAR=XXX
    $ cat << END
    > dk
    > \$VAR
    > END
    dk
    $VAR
    

提交回复
热议问题