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 Chief Operating Officer of HCS Technology Group, Keith plays a pivotal role in driving operational excellence and technical innovation.

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