Displaying octal numbers in bash

David A. Bandel david
Mon May 17 11:54:04 PDT 2004


On Thu, 25 Sep 2003 08:40:02 +0200
Roger Oberholtzer <roger at opq.se> wrote:

> 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'.

from the man page:

       By  default, date pads numeric fields with zeroes.  GNU date
recognizes
       the following modifiers between `%' and a numeric directive.

              `-' (hyphen) do not pad the field `_' (underscore) pad the
field
              with spaces


Ciao,

David A. Bandel
-- 
Focus on the dream, not the competition.
		Nemesis Racing Team motto
GPG key autoresponder:  mailto:david_key at pananix.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.linux-sxs.org/pipermail/linux-users/attachments/20030925/3c098f06/attachment.pgp


More information about the Linux-users mailing list