Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 9
    Those man pages are for the system-supplied echo command, /bin/echo, which on Mac OS has no -e option. when you're using bash on those systems, its built-in echo command takes over. You can see this by explicitly typing /bin/echo whatever and observing the difference in behavior. To see the documentation for the built-in, type help echo.
    – Mark Reed
    Commented Jun 10, 2012 at 16:59
  • 1
    /bin/echo is often different from one OS to another and different from Bash's builtin echo. Commented Jun 10, 2012 at 17:01
  • @MarkReed: I'll try later, but thanks for the info. +1. I will just leave my answer here, since there are quite a lot of good discussion going on.
    – nhahtdh
    Commented Jun 10, 2012 at 17:01
  • 11
    echo -e is not portable -- for example, some implementations of echo will print the "-e" as part of the output. If you want portability, use printf instead. For example, /bin/echo on OS X 10.7.4 does this. IIRC the bash builtin echo was also weird under 10.5.0, but I don't remember the details any more. Commented Jun 10, 2012 at 17:02
  • 2
    echo -e has bitten me before... Definitely use printf or cat with a heredoc. The <<- variant of here docs are especially nice because you can strip leading indentation in the output, but indent for readability in the script
    – zbeekman
    Commented Jun 7, 2017 at 2:10