| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT 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 AT panix DOT com> |
| cc: | cygwin AT cygwin DOT 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 DOT post AT talk DOT nabble DOT com> |
| MIME-Version: | 1.0 |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT 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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |