Linux.com

enhancement of echo

Link to this post 16 Jun 09

what r the drawbacks of echo command? can u plz suggest some enhancements in echo command.

Link to this post 17 Jun 09

Hum... interesting question. Echo is a simple program, with plenty of options already (man echo for details ^_^).

So I guess it is quite complete already. I never encountered snaggs with echo.

Link to this post 17 Jun 09

gr8linux wrote:

what r the drawbacks of echo command? can u plz suggest some enhancements in echo command.

well, i don't know if it is a drawback, per se, but there is a built-in function in the shell (I use bash) call echo. This sometimes confuses me when I think I'm calling the echo utility from gnu coreutils.

I personally prefer to use printf, b/c I like the greater flexibility it has in string formatting, etc.

Link to this post 17 Jun 09

[b]
I personally prefer to use printf, b/c I like the greater flexibility it has in string formatting, etc.

can u plz gv me some examples of why u prefer printf and how it is more flexible than echo.......i m looking for that. i wanna know what uses r missing in echo.

Link to this post 17 Jun 09

gr8linux wrote:

[quote][b]
I personally prefer to use printf, b/c I like the greater flexibility it has in string formatting, etc.

can u plz gv me some examples of why u prefer printf and how it is more flexible than echo.......i m looking for that. i wanna know what uses r missing in echo.[/quote]

make some nice columns in output:

printf "%-20s%s\\n" meh blah
printf "%-20s%s\\n" foo bar

round up to a whole number:

printf '%0.f\\n' 1.5

convert hex to decimal:

printf '%d\\n' 0x100000000

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board