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.

Marianne Carroll

Marianne began her professional career as a musician, recording and touring as a violinist with the 70’s disco sensation CHIC. She then moved into music management as the Executive Director of the Aston Magna Foundation for Music, which sponsored a Summer classical music festival and NEA-funded cross-cultural educational Academy in the Berkshires as well as a concert series at the Metropolitan Museum.

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