where is the diff: in these two program
here are the two codes
1> code 1 #!/bin/sh echo -n "enter file name" read file c=0 sum=0 avg=0 cat $file |{ while read line; do c=$(expr $c + 1) sum=$(expr $sum + $c) echo $$ #avg=`expr $sum / $c` done } echo $$ echo $? echo c= $d echo sum= $sum echo $avg= `expr $sum / $c` 2> code 2 #!/bin/sh echo -n "enter file name" read file c=0 sum=0 avg=0 while read line; do c=$(expr $c + 1) sum=$(expr $sum + $c) echo $$ #avg=`expr $sum / $c` done < $file echo $$ echo $? echo c= $d echo sum= $sum echo $avg= `expr $sum / $c` -------------------------------------------------------------------- I'm getting solution from second code,... what i'm thinking is that processes is being forked as we called CAT command but not fully satisfied Can ny body help me? |
|
All times are GMT -5. The time now is 01:23 AM. |