On Tue, 1 Sep 2009, Linda Walsh wrote:

> 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/')
    Surely you mean:

lastmo=${lastmo#0}

-- 
   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


Reply via email to