Welcome to the Linux Foundation Forum!

enhancement of echo

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

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • 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.
  • Posts: 216
    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.
  • Posts: 26

    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.
  • Posts: 216
    gr8linux wrote:

    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.

    make some nice columns in output:
    1. printf "%-20s%s\\n" meh blah
    2. printf "%-20s%s\\n" foo bar

    round up to a whole number:
    1. printf '%0.f\\n' 1.5

    convert hex to decimal:
    1. printf '%d\\n' 0x100000000

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training