So i am trying to create a script inside another script, but the issue i have encountered is that the variables in the script i am trying to create are getting filled by the script that is creating it. That is a little confusing, but i think it makes sense. Ill give an example...
#/bin/bash
cat <<EOF | tee -a ./newscript.sh
variable1=$(ls /home/ | wc -l)
variable2=$(expr $variable1 + 1)
EOF
The results of this script create a script that has those values filled out already, like this
variable1=*some number*
variable2=*another number*
The intended result would be to add that entire section of code into the script unchanged. How would I do this? My current workaround is just using wget to get the script from github, but i would much rather have it be all contained in one script without having to call out to another service to work. Thanks