[clue] shell scripting Q

Daniel Fritz fritzdan at gmail.com
Mon Feb 11 15:27:31 MST 2013


echo "scale=2;$total/60" | bc works


On Mon, Feb 11, 2013 at 3:24 PM, Mike Bean <beandaemon at gmail.com> wrote:

> I've got a script I'm trying to finish, the problem in a nutshell however
> is that bash appears to treat all arithmatic as real numbers/integers, and
> while I don't need accuracy down to the 10th place, down the 2nd place
> would be nice.
>
> In my research I found echo 'scale=2;87/60' | bc
> which works well, however the problem is I'm not going to know the first
> term, I've got to be able to pass it a variable, and all attemptse to date
> have resulted in:
>
> bash-4.1$ echo 'scale=2;$total/60' | bc
> (standard_in) 1: illegal character: $
>
> (scratches head)
>
> Mike
>
> _______________________________________________
> clue mailing list: clue at cluedenver.org
> For information, account preferences, or to unsubscribe see:
> http://cluedenver.org/mailman/listinfo/clue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue/attachments/20130211/0c61cdb3/attachment.html 


More information about the clue mailing list