Illegal character ^M

Erwin Waterlander waterlan@xs4all.nl
Sat Dec 3 07:32:00 GMT 2011


frenco schreef, Op 29-11-2011 19:57:
> I have a problem with a character. I think it's a conversion problem between
> dos and unix.
>
> I have a variable that is a float value.
> When I print it with the echo command i get:
> 0.495959
> 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
>
>   I get:
> (standard_in) 1 : illegal character: ^M
>
> I already use the dos2unix command on my .sh file.
> I think it's because my variable have the ^M character (not printed with the
> echo command)
>
> How can i eliminate this error?

Hi,

Dos2unix will convert only DOS line breaks to Unix line breaks. Meaning 
\r\n to \n.
When you see a single \r (^M), without a following \n, this is a Mac 
line break.
Dos2unix will leave Mac line breaks alone.
So you need to run mac2unix instead of dos2unix on the file.

regards,

-- 
Erwin Waterlander
http://waterlan.home.xs4all.nl/


--
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



More information about the Cygwin mailing list