There are time when you need to escape special characters in a bash script like dollar signs or backticks.  If you ever need to quote an entire section of text in a bash script without having to escape all special characters, use the cat command with EOF in single quotes.

When EOF is enclosed in single quotes, it ignores any special characters and will not interpret them in your script.  

The following command will print out the lines in between ‘EOF’ and EOF to the screen.


cat << 'EOF'

Lines with $signs are OK

Line with `backticks`

EOF


This is a handy command for your arsenal.  Enjoy.

Keith Mitnick

As Senior System Engineer & COO at HCS, Keith wears many hats. He is responsible for a myriad of duties at HCS. Keith is always willing to do the job at hand and is never afraid to get his hands dirty.

Speak with an Apple Certified expert today

We’d love to discuss your business challenges, even if you’re not sure what your next step is. No pitch, no strings attached.

Let's Talk