X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0	tests=AWL,BAYES_00,MISSING_HEADERS,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Date: Tue, 29 Nov 2011 14:22:56 -0600 (CST)
From: Tim McDaniel <tmcd@panix.com>
cc: cygwin@cygwin.com
Subject: Re: Illegal character ^M
In-Reply-To: <32881791.post@talk.nabble.com>
Message-ID: <Pine.NEB.4.64.1111291416260.19989@panix3.panix.com>
References: <32881791.post@talk.nabble.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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

