|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
can anyone explain me what is the difference between echo and print in shell programming?
|
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
print and echo
both echo and print are common in working ...
both displays the chars on the screen or windows. upto me using print we can redirect the output to any file descriptor using print -u[n] but for echo we have to redirect using redirection operator or using pipe. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
echo & Print
Print - You can format the output
Echo - displys the output as such and it is comparitively faster than print. |
|
#4
|
||||
|
||||
|
With ksh at least both echo and print are very fast built-in commands. Dave Korn added print to ksh. At the time ksh was developed Unix was split into a BSD and USG. And the echo statement was different. On BSD, "echo -n" would display no output but on USG it would display "-n". On USG, "echo \\c would display no output, but on BSD it would display "\c". So a portable shell script needed to capture and test the output from "echo -n" and then you could do:
if [ $ECHOTYPE = BSD ] ; then echo -n "enter name - " ; else echo "enter name - \\c" ; fi Dave felt that rather than trying to solve the echo dichotomy, he would leave "echo" alone and go with "print" which was his own creation. "print" would be the same everywhere. And he added a lot of new stuff to "print". Later, Posix decreed that the USG echo was standard. And it defined "printf" as a new, more powerful tool. So while Posix encourages the use of "printf", "echo" is now standard too. "print", on the other hand, is a non-standard feature of ksh. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| echo/print variable question | riegersteve | Shell Programming and Scripting | 1 | 09-02-2010 03:05 PM |
| Differenc between ps -ef and top | Amey Joshi | UNIX for Dummies Questions & Answers | 2 | 02-12-2009 12:29 PM |
| how to print backslah using echo | mani_um | Shell Programming and Scripting | 8 | 04-12-2007 01:05 PM |
| echo vs. print | PhilW | UNIX for Dummies Questions & Answers | 1 | 03-03-2004 11:21 AM |
| echo or print to screen and file | Shakey21 | UNIX for Dummies Questions & Answers | 2 | 01-09-2002 06:56 PM |
|
|