On Tue, 29 Nov 2011, frenco wrote:
I have a variable that is a float value.
When I print it with the echo command i get:
0.495959
...
I think it's because my variable have the ^M character (not printed
with the echo command)

You might try
    echo "[$the_variable_name]"
The quoting is significant.  If it does have a carriage return like
you think, then it will probably display like
    ].495959
That is, the ^M will probably make it go back to the start of the
line, and characters after it (here, ]) will overwrite what it output
before.

But when I try to make an operation on that value with the bc
command (I am not sure how to write the bc command).
echo $mean *1000 |bc
...
How can i eliminate this error?

    echo $mean *1000 | tr -d '\r' | bc
seems to work.  "tr" translates characters, "-d" says that instead of
translating it should just delete the name characters, and '\r' (note:
single quote ', not double quote ") is the ^M character.

--
Tim McDaniel

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to