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?
You can disable parameter expansion in here documents by quoting the limit string:
cat >aBashScript.sh <<'EOL'
$name
EOL
You need to escape the dollar sign, simply prefix it with a backslash to escape it like so:
cat >aBashScript.sh <<EOL
\$name
EOL
Or disable quoting as @Michael suggested.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With