By Keith Mitnick on Wednesday, 22 June 2016
Category: General

Using the EOF (End of File) Command

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.
Leave Comments