On Thu, 18 Apr 2002, at 9:17pm, Paul Iadonisi wrote:
> The 'date +%j' command returns a number with a leading zero.  To the 'let'
> assignment this looks like an octal number, but the digit '9' is 'too
> great for base' (base being 8).  Haven't found an elegant way to fix it
> yet, if I figure it out, I'll 'let' you know ;-).

  When all else fails, RTFM.  :-)  Mine tells me (under "ARITHMETIC
EVALUATION") that:

       Constants with a leading 0 are interpreted as  octal  num-
       bers.  A leading 0x or 0X denotes hexadecimal.  Otherwise,
       numbers take the form [base#]n, where base  is  a  decimal
       number  between 2 and 64 representing the arithmetic base,
       and n is a number in that base.

  So, if you do this

        let due=10#`date +%j -d 04/01/2002`

it forces bash to evaluate the "091" in base 10, and it works.

  While we are on the subject of shell programming, it is better to use this

        let due=10#$(date +%j -d 04/01/2002)

construct.  The $(...) syntax can be nested, and is easier to read than the
`...` syntax.

-- 
Ben Scott <[EMAIL PROTECTED]>
| The opinions expressed in this message are those of the author and do not |
| necessarily represent the views or policy of any other person, entity or  |
| organization.  All information is provided without warranty of any kind.  |


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to