On 2015-04-02, Hongyi Zhao <
hongy...@gmail.com> wrote:
> Hi all,
>
> See the following snippets:
>
> cat << EOF
> \$
> $
> EOF
>
> Bu running it, I will obtain the following result:
>
> $
> $
>
> So, if I want to obtain the literal character `$' in heredoc with its
> expanded behavior enables, which form should I use?
Your requirement is contradictory. If the character $ is "literal",
that precisely means that its special behavior is disabled.
# cat << EOF
$TERM
\$TERM
EOF
xterm
$TERM
If $ is followed by whitespace, or the end of the line, then even if it is not
escaped, it just denotes itself:
# echo $ $
$ $