I'm having a problem with bash variable substitution. Here's a silly example of what I am trying to do. I need to output a new script from a bash script. A line (see echo in my example) has a mixture of variables that should not be replaced and variables that should be replaced. #!/bin/bashREPLACE=`whoami`cat << EOF > mynewscript.sh    read DONTREPLACE < /home/$REPLACE/localinput.txt    echo $DONTREPLACE > /home/$REPLACE/somefile.logEOFexit 0This isn't a real example, but it does illustrate the problem. Let's say that I need to know the absolute path in advance and that I want $REPLACE evaluated in my original script. But I do NOT want $DONTREPLACE evaluated/replaced in my script. $DONTREPLACE should be output exactly like that to the new script.Therefore, quoting 'EOF' in making the here document doesn't work.I hope I'm explaining this well enough.I don't know of another solution. I appreciate any ideas, but I prefer really simple ideas/solutions. It doesn't have to be elegant. 
using bash script to output new script: need mixture of variables to be replaced and not replaced
bash;echo;variable substitution;here document
You should use \ to escape the $ in front of DONOTREPLACE. See example and output belowREPLACE=10DONOTREPLACE=20cat <<EOF> echo $REPLACE> echo \$DONOTREPLACE> EOFecho 10echo $DONOTREPLACE