# Availability: echo vs. printf?

**URL:** <https://community.unix.com/t/availability-echo-vs-printf/347941>\
**Category:** Linux\
**Created:** [November 9, 2014, 5:39am UTC](https://community.unix.com/t/availability-echo-vs-printf/347941 "2014-11-09T05:39:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sea](https://community.unix.com/user_avatar/community.unix.com/sea/32/2946_2.png) [@sea](https://community.unix.com/u/sea)\
**Post date:** [November 9, 2014, 5:39am UTC](https://community.unix.com/t/availability-echo-vs-printf/347941/1 "2014-11-09T05:39:12Z")

</div>

Hello,

For some reason i dont remember, i currently believe (but beeing unsure) that `printf` is available on more diffrent systems (unix, bsd, linux, ??) than `echo` is.

Could someone please enlighten me, whether this is true or not?  
Thank you

PS:  
I just found pages about the diffrences of the two commands, but not where they are available or not.

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [November 9, 2014, 6:29am UTC](https://community.unix.com/t/availability-echo-vs-printf/347941/2 "2014-11-09T06:29:22Z")

</div>

The `printf` utility has been almost universally available for more than 2 decades and is a built-in in almost all current shells. There is a large set of conversion specifiers that behave the same way on all systems and in all shells. (Some shells provide extensions that supply additional conversion specifiers.)

The `echo` utility has been universally available for more than 4 decades and is a built-in in almost all current shells. The meaning of various options and backslash escape sequences recognized by `echo` varies from system to system and shell to shell.

---

<div class="post-metadata">

**Author:** ![sea](https://community.unix.com/user_avatar/community.unix.com/sea/32/2946_2.png) [@sea](https://community.unix.com/u/sea)\
**Post date:** [November 9, 2014, 7:32am UTC](https://community.unix.com/t/availability-echo-vs-printf/347941/3 "2014-11-09T07:32:58Z")

</div>

So, to say it simple ( one could also say):

- Both should be available on almost all systems?
- And to print a simple "Hello World", the main reason to choose one or the other tool would be personal preference?

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [November 9, 2014, 7:53am UTC](https://community.unix.com/t/availability-echo-vs-printf/347941/4 "2014-11-09T07:53:13Z")

</div>

As I have said in dozens of other threads in these forums: if the first character of the first argument is a minus sign, if any argument contains a backslash, if you do not want to have a newline printed at the end of the output, or if any argument contains user-supplied data; use `printf` , not `echo` . Otherwise, it doesn't matter whether you use `printf` or `echo` .
