On 06/23/2010 07:01 PM, Andres P wrote:
> On Wed, Jun 23, 2010 at 8:23 PM, Peng Yu <pengyu...@gmail.com> wrote:
>> Why printf is better than echo? Is this because printf is more robust than 
>> echo?
> 
> Because if a string that is to be printed happens to be an echo flag, such
> as -n or -e, there's no straight forward way of escaping it such as
> with printf %s.
And because if a string to be printed contains a backslash, behavior
differs wildly between shells on whether echo prints the backslash
literally or treats it as an escape, whereas with printf the behavior is
consistent.

And because POSIX says so.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to