Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: padding.



Ray Andrews wrote on Fri, Feb 10, 2017 at 19:15:14 -0800:
> $ integer -x vvar=-1
> $ echo ${(l:5::0:)vvar}
> 
> 
> 000-1
> 
> 
> How do I get "-00005"? But also with the negative not counting as part of
> the padding?  Or is this a job for printf?  It seems to be asking quite a
> bit from zsh itself.

${(l)} is a string operator:

% integer x
% echo ${(l:5::x:)x}
xxxx0

So, yes, use printf %05d.



Messages sorted by: Reverse Date, Date, Thread, Author