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.

7
  • There will be a echo builtin in every shell available on the system. On Ubuntu /bin/sh is usually dash, bash also comes by default. zsh, rc, mksh, yash, csh, tcsh, ksh93... will all have their own echo with different behaviour. Note that which echo will not give you the path of the system echo in all shells. Commented Feb 22, 2016 at 20:43
  • @StéphaneChazelas "which echo will not give you the path of the system echo in all shells." That I didn't know, what else could it give? Commented Feb 22, 2016 at 20:46
  • Try in tcsh or zsh. which was originally (in the 80s) a csh script for csh users only (loaded the aliases from ~/.cshrc) and still is on some systems. which is a builtin in zsh and tcsh. Commented Feb 22, 2016 at 20:49
  • printf will break if the text has % on it (probably among others) and the 'bash support to escape special characters' to avoid that prints the escape to the file, which you obviously don't want. Commented Dec 12, 2021 at 17:13
  • 1
    @i30817 yes, gotta use printf '%s\n' Commented Dec 12, 2021 at 17:14