Out of curiosity and the perfectionist in me, I “had” to print a line of text in the output inside a BASH shell script. I didn’t really want to split them into multiple echo statements since it’s a waste of space and actually harder to read for me. The first thing I tried was:
> echo “Line1\nLine2″ # Line1\nLine2
That clearly didn’t work out so well… so I thought maybe my Mac (OS X 10.5.7) likes ‘\r\n’ more:
> echo “Line1\r\nLine2″ # line1\r\nline2
Still nope! As I found out later on though, not all versions of echo supports backslash escape characters. A quick look up in the MAN page for echo revealed that I needed to pass in the -e option in order to enable this capability:
> echo -e “Line1\nLine2″
Line1
Line2
TADA! Third time is the charm!

