Re: Echo vs Print



On Wed, 1 Jun 2005 15:11:34 -0700, "Tony" <someone@xxxxxxxxxxxxx> wrote:

>I'm just wondering why it seems most people use "echo" instead of "print". I
>tend to use "print", probably because I started programming in BASIC back in
>78, so it's just familiar.
>
>Echo can take multiple expressions (as in "echo
>$string1,$string2,$string3"), which apparently is a bit faster than multiple
>concatenations. But for basic output, there doesn't seem to be a noticeable
>difference. The speed test at http://dynacker.dotgeek.org/printvsecho/ shows
>a "5%" difference in speed, but this amounts to a negligible difference in
>actual execution time on a typical script.
>
>So - why does one choose "echo" over "print", or vice-versa?

I use print, with the only reason being that I am quite fond of printf - so if
I change a line from print to printf I only need to add a character.

Possibly with a further reason that I use Perl a bit as well, which uses
'print'.

--
Andy Hassall / <andy@xxxxxxxxxxx> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
.



Relevant Pages

  • Re: bash question
    ... echo "$x: " ... Is there a reason for using while instead of for? ... Jacques B. ...
    (Fedora)
  • Re: Alkans Sonate de Concert for cello and piano
    ... There's no good reason for it to be specialist (other than technical=20 ... to be a concert standard (other than the sheer technical difficulty of=20 ... I'd love to attend a good live performance. ... I echo your sentiments - for all of the Alkan chamber music. ...
    (rec.music.classical.recordings)
  • Re: [PHP] Include???
    ... On 5/23/07, Jim Lucas wrote: ... > The echo of my status_code retruns the correct value so the if should ... but for some reason is not working???? ... "Some men are born to greatness, some achieve greatness, ...
    (php.general)
  • Re: Increment counter upon each execution of shell script
    ... The reason for this counter is that the way that the files that I wish ... echo $)>counter.$$ ... mv -f counter.$$ counter || exit 1 ...  It should at least avoid corrupting ...
    (comp.unix.programmer)
  • Re: HELP! Scripting newbie question.
    ... printf "File: $file\n" ... There is nothing in your script to do the expand of the $1. ... insert a test by doing an echo $list or echo $1 in your srcipt to ...
    (comp.unix.solaris)