using bc with floating point number in files

Hi,
I' using bash and I would like to use "bc" to compute the ratio of of two numbers and assign the ratio to a variable.
The numbers are in a file, e.g.
196.304492
615.348986

Any idea how to do it?
N.B. I cannot change the file to have 196.304492 / 615.348986 as the file is produced by another code.

Thank you for your help,
Sarah

bash-3.00$ bc
scale=10
196.304492/615.348986
.3190132696

or

bash-3.00$  printf "%s\n" 'scale = 10; 196.304492/615.348986' | bc
.3190132696

or even:

bash-3.00$ x=$( printf "%s\n" 'scale = 10; 196.304492/615.348986' | bc)
bash-3.00$ echo $x
.3190132696

HTH

Maybe I was not clear enough, the numbers are in a file containing these 2 numbers, one in each line.
So my guess would be that I need somehow to create a file or a string from the content of the file...but I can't figure out how.
Thank you,

Option 1:

$( cat file | tr '\n' '/'|sed -e 's#/$#\n#'|bc )

Option 2:

$( cat file |perl -e '@v=<>; print $v[0]/$v[1];' )

I would like to try something like Option 1 of pludi
however it seems not to work, maybe because in the file I have a new line character after each number.

The first one should work, since the tr takes care of the newline. If the file is generated with MS-DOS/Windows style line terminators, modify the line to read

cat file | tr '\r' ' ' |tr '\n' '/'|sed -e 's#/$#\n#'

I'm lost.

in tmp.tmp1 I managed to have something like

in the script I have

but it won't work!

This wont work because sed requires the input to already have a newline in it to process the line. The line coming out of the tr command does not contain a new line, so sed will ignore it.

What you can do is this

 
echo $(sed -e 's#$#\#') 1.0 | bc -l
 

vgersh99 had a post on this yesterday. If I figure out how to make a nice link I'll put it here.

Go to This link for vgersh99's description of how this works.

I get

Given the myFile content like so:

196.304492
615.348986

.....

#!/bin/ksh

echo "scale=10;$(tr '\n' '/' < myFile;)1"|bc

From the link you gave me

works fine if I need the sum, but not the ratio... (replacing + with / doesn't work)

finally it worked, thank you all!

And you changed the zero to a one?

Also, if using the s/ / / delimiter did you escape the division operator?

's/$/\//'

I used

echo "scale=10;$(tr '\n' '/' < myFile;)1"|bc

changing just the name of the file