![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to assign the specific value | ryanW | Shell Programming and Scripting | 4 | 04-20-2009 10:20 PM |
| Assign o/p of awk to a variable | c2b2 | Shell Programming and Scripting | 8 | 04-01-2009 07:50 AM |
| how to assign the first day of the next month | rosalinda | Shell Programming and Scripting | 6 | 07-05-2008 04:13 PM |
| Assign variables with cut | douknownam | Shell Programming and Scripting | 2 | 09-27-2004 09:18 AM |
| assign to variable | AkumaTay | UNIX for Dummies Questions & Answers | 1 | 05-18-2002 02:11 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Friends here is code which is used to add floating point using bc, but I m not getting any output instead some errors.
Code:
1 #!/bin/bash 4 if [ -c /proc/$$/fd/0 ] 5 then 6 echo "Our input is from a Device" 7 while read myline 8 do 9 10 total= `echo $total + $myline |bc` 11 #((total=$total+ $myline)) 12 done 13 14 elif [ -p /proc/$$/fd/0 ] 15 then 16 17 echo "Our input is from a pipe" 18 while read myline2 19 do 20 total= `echo $total + $myline |bc` 21 #((total= $total+ $myline2)) 22 done 23 elif [ -f /proc/$$/fd/0 ] 24 then 25 26 echo "Our input is from a file" 27 while read myline3 28 do 29 add=+ 30 $(($total $add $myline))| bc 31 #echo $total $myline 32 #total= echo `$total $add $myline |bc` 33 #((total= $total+ $myline)) 34 done 35 36 37 38 echo "Error" 39 break; 40 fi 41 42 echo total is $total Last edited by Franklin52; 04-25-2009 at 09:00 AM.. Reason: adding code tags |
| Bookmarks |
| Tags |
| adding, assigning values, bc |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|