www.delorie.com/gnu/docs/textutils/coreutils_137.html   search  
 
Buy GNU books!


GNU Core-utils

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21.1.4 Padding

By default, date pads numeric fields with zeroes, so that, for example, numeric months are always output as two digits. GNU date recognizes the following numeric modifiers between the `%' and the directive.

`-'
(hyphen) do not pad the field; useful if the output is intended for human consumption.
`_'
(underscore) pad the field with spaces; useful if you need a fixed number of characters in the output, but zeroes are too distracting.

These are GNU extensions.

Here is an example illustrating the differences:

 
date +%d/%m -d "Feb 1"
=> 01/02
date +%-d/%-m -d "Feb 1"
=> 1/2
date +%_d/%_m -d "Feb 1"
=>  1/ 2


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003