Timeline for How to output a multiline string in Bash?
Current License: CC BY-SA 4.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 28, 2023 at 23:02 | history | edited | Dharman♦ | CC BY-SA 4.0 |
deleted 318 characters in body
|
Jun 7, 2017 at 2:10 | comment | added | zbeekman |
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
|
|
Jun 10, 2012 at 17:02 | history | edited | nhahtdh | CC BY-SA 3.0 |
added 7 characters in body; Post Made Community Wiki
|
Jun 10, 2012 at 17:02 | comment | added | Gordon Davisson |
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.
|
|
Jun 10, 2012 at 17:01 | comment | added | nhahtdh | @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. | |
Jun 10, 2012 at 17:01 | comment | added | Dennis Williamson |
/bin/echo is often different from one OS to another and different from Bash's builtin echo .
|
|
Jun 10, 2012 at 16:59 | comment | added | Mark Reed |
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 .
|
|
Jun 10, 2012 at 15:35 | history | edited | nhahtdh | CC BY-SA 3.0 |
added 293 characters in body
|
Jun 10, 2012 at 15:29 | history | answered | nhahtdh | CC BY-SA 3.0 |