bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doing simple math in bash :: prb with leading zero


From: Linda Walsh
Subject: Re: doing simple math in bash :: prb with leading zero
Date: Tue, 01 Sep 2009 14:59:06 -0700
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

ken wrote:
Doing very simple math in bash fails if a number begins with a zero (0).
 The short script below illustrates the problem:
---
Normally, a leading 0 begins an octal constant (I have been bitten
by this in the past as well...).

Where are you getting the value 'lastmo' from?

If from 'something like date +"%m"', maybe you could strip off the leading zero? I.e.:

 lastmo=$(echo "$lastmo"|sed -r 's/0+([0-9])/\1/')





reply via email to

[Prev in Thread] Current Thread [Next in Thread]