October 05, 2023, 02:44:02 AM

News : LinuxSolved.com Linux Help Community Forum..

Author Topic: Need Help with Math in Redhat  (Read 5036 times)

Offline coyboss

  • Linux Noob !
  • *
  • Posts: 4
Need Help with Math in Redhat
« on: August 21, 2011, 12:50:51 PM »
Code: [Select]
Hi all,
I am trying to figure out how to use a math command to divide one file by another then pipe it to a file.
I have too files one with a value of 10 (lets say file1) and one with a value of 200 (lets say file 2), I need to divide file 2 by file 1 and had results sent to a file (lets say file 3). I am working out of a book and don't quite understand which operations to use or how they are supposed to be combined.

Here is what I have so far:

Code: [Select]
var3=`echo "var1=file2; var2=file1; var1 / var2" | bc`
echo output=file3
 but I keep getting the following error.
 [ Ike]$ ./Week3prog3Ike.scr
 Runtime error (func=(main), adr=15): Divide by zero
I have tried it this way too
Code: [Select]
read File2
read File1
var3=`echo "var1=File2; var2=File1; var1 / var2" | bc | output=File3`

and  I am getting this error output:

 [Ike]$ ./Week3prog3Ike.scr
 (standard_in) 1: parse error
 (standard_in) 1: parse error

Thanks in advance.
« Last Edit: August 21, 2011, 12:56:15 PM by coyboss »