the "cmd <<EOL ..\n..\n EOL" part has been mystical to me for ages, especially as I didn't know what to google to find out. I recently learned it was called a "Here Document". http://en.wikipedia.org/wiki/Here_document
For extra credit, try using a "Here Document" as input for 'echo' and 'cat'. Explain the results.
For extra credit, try using a "Here Document" as input for 'echo' and 'cat'. Explain the results.