Displaying octal numbers in bash

Roger Oberholtzer roger
Mon May 17 11:54:04 PDT 2004


While on the octal front, anyone know how to get the date command, when
used with format specifiers, NOT to prefix a number with a zero? I use it
in a Makefile to put a time stamp in a C program, but the leading 0 forces
the compiler to think it is octal. So, this month '09' is not accepted.
Offending are month, hour and minute. day and year have a format without
leading 0.

e.g.;

	date +%m

gives '09'.


On Wed, 24 Sep 2003 21:00:08 -0400
Joel Hammer <Joel at hammershome.com> wrote:

> I understand that bash will do arithmetic in octal if you prefix the
> constant with 0. So:
> a=05
> b=017
> c=$((a*b))
> echo $c
> yields
> 75
> This is the correct answer, but it is in decimals, not octals.
> Is there a way to make echo display octal?
> Thanks, 
> Joel



-- 
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer          ?   E-mail: roger at opq.se        ?
? OPQ Systems AB             ?      WWW: http://www.opq.se/  ?
? Erik Dahlbergsgatan 41-43  ?    Phone: Int + 46 8   314223 ?
? 115 34 Stockholm           ?   Mobile: Int + 46 733 621657 ?
? Sweden                     ?      Fax: Int + 46 8   302602 ?
+????????????????????????????+???????????????????????????????+



More information about the Linux-users mailing list