bash echo on OSX

On 2012/09/19, in rant, by a b

Because echo is a build in command for the Bash implementation on OSX, there’s a discrepancy between the man page and how it actually works. Most interesting (to me) in all that is you can actually use the -e flag for quoted echo output. That makes using \n a nice way to add some line breaks. Not that I fiddle around too much with my bash scripts. Heck no.

Instead of echo “” or echo. to create one break, you can echo “Something \n Other Things” and get wrapping all in one statement. You also get a stack of other escape values. Check out the Unix echo man page for some ideas.


~ $echo "Gort\nklaatu\nbarada\nnikto"
~ $echo -e "Gort\nklaatu\nbarada\nnikto"
~ $

Nerd joy FTW!


Comments are closed.