I am having trouble with writing case $1 in a bash file. I tried with  cat <<EOT > /etc/init.d/startup.sh#!/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/bincase $1 in    start)        bash /root/install.sh >> /root/installation_log.txt 2>&1        ;;    stop|restart|reload)        ;;esacEOTBut the problem is it writes everything to startup.sh but $1. Line   case $1 in  become case  in after the operation.What to do?
How to write text containing $var to a bash file?
shell script;files;write
Quote the EOF terminator passed to the << operator (in any way):cat << 'EOT' > file$varEOTOrcat << \EOTcat << EO\Tcat << E'O'Tcat << EOTThat's the documented and standard way to prevent any type of expansion inside the here-document.