How can I suppress parameter expansion in a here-doc in Bash?

bash

Solution

You can disable parameter expansion in here documents by quoting the limit string:

cat >aBashScript.sh <<'EOL'
$name
EOL

Problem

I'd like to do the following in bash, but without having variables interpolated: ``` cat >aBashScript.sh <<EOL $name EOL ``` The file should contain `$name`, but instead it's empty. How does one do that?

Original source