I'm using bc and it is ok. The problem is I cannot put a number next to the output. I cannot command the echo with "-n parameters". After I get the value, I need to put another value next to it which is having an error
if [ $grep2a_1 -eq "1" ]; then echo -n "$time," echo "scale=3; $com2_1 / 1000" | bc (If I change this line to echo -n "scale=3; $com2_1 / 1000" | bc, it has an error) else echo "test" fi ----- Original Message ---- From: andrelst <[EMAIL PROTECTED]> To: Philippine Linux Users' Group (PLUG) Technical Discussion List <plug@lists.linux.org.ph> Sent: Saturday, December 1, 2007 10:22:13 AM Subject: Re: [plug] How to display remainder in Bash script expr only does integers, which the man pages in Linux sadly omits. Solaris explicitly says it in the man page that it's only for integers. go for bc if you want remainders: $ echo 5 / 3 | bc -l 1.66666666666666666666 -- regards, Andre | http://www.varon.ca On Nov 30, 2007 8:49 PM, Nelson Serafica <[EMAIL PROTECTED]> wrote: > > > I'm trying to create a script that will convert b/s to kb/s. To convert to > kb/s, I must divide it to 1000 b/s. However, the answer does not contain the > remainder. When I do "expr 5 / 3", it shows only 1 (suppose to be 1.6). > Doesn't show the remainder .6. > > I search in Google and it says the "%" is remainder of a division. But when > I do expr 5 % 3, it shows "2". It suppose to be 6, am I right? > > > Any inputs, _________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List plug@lists.linux.org.ph (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph ____________________________________________________ Organic foods - just how healthy is health food? Be a better foodie Find out at Yahoo! Answers - http://ph.answers.yahoo.com/
_________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List plug@lists.linux.org.ph (#PLUG @ irc.free.net.ph) Read the Guidelines: http://linux.org.ph/lists Searchable Archives: http://archives.free.net.ph