On Fri, 21 Oct 2011 10:43:44 -0500 Scot Jenkins wrote:
> Glenn Fowler wrote:
> > %0s was added 2011-03-10
> For give me I don't have 2011-03-10 handy.
> Is '0' replacing the '.' for strings?
> These seem to work as expected:
> $ printf "%.0s\n" foo
> $ printf "%.2s\n" foo
> fo
the new form is
%0<width>s
where <width> is a positive integer
at most the <width> *trailing* characters of the string are printed
(it truncates from the head)
this form
%.<width>s
at most the <width> *leading* characters of the string are printed
(it truncates from the tail)
for example:
$ printf $'%.4s\n' 123456789
1234
$ printf $'%04s\n' 123456789
6789
this is handy when listing column limited data where the significant
info is in the tail (e.g., path names)
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers