Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: padding.
- X-seq: zsh-users 22448
 
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
 
- To: Zsh Users <zsh-users@xxxxxxx>
 
- Subject: Re: padding.
 
- Date: Sat, 11 Feb 2017 11:04:37 -0800
 
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;        h=from:message-id:date:in-reply-to:comments:references:to:subject         :mime-version;        bh=OGOf+ZXHA9eSZlchCbLci6oaVbvYv817vDz74pzT6Yw=;        b=uVkxdWeun2Dc+grY9rIU4vpuDnPErBiCb4KvAB8UVE9sSB49ySDgO4VK9sEQkrnEnI         4ZFobEVmAj00DN1C3LXWuRn3nmATn35ZnT3C9o98BKtZSn8c1lM3LjiQTpwvFfeCr8Ca         QjO4gRvqNz7MLnThu9m6IHBSePQTcWHVJwGsaD+0tzjIIkhdBxnjk2xTm86iJocrKJFS         yLHgVzmxppTjmCIpc0mOyaFT2szZQsbrHmxWNfrta/KM2x6uxdJL9cEZW5bzU23cksgc         joI5Uw5a6Wln6F/XAs5pRbSWSHTTh4C9eYeWjyz/p3ZqEK7JQpBNkQkmU8KxBgLDdCrt         jlTA==
 
- In-reply-to: <0befdb38-eaa5-6388-a3fe-58b1a73834b7@eastlink.ca>
 
- List-help: <mailto:zsh-users-help@zsh.org>
 
- List-id: Zsh Users List <zsh-users.zsh.org>
 
- List-post: <mailto:zsh-users@zsh.org>
 
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
 
- References: <0befdb38-eaa5-6388-a3fe-58b1a73834b7@eastlink.ca>
 
On Feb 10,  7:15pm, Ray Andrews wrote:
} Subject: padding.
}
} $ integer -x vvar=-1
} $ echo ${(l:5::0:)vvar}
} 
} How do I get "-00005"?
In addition to the suggestion of printf,
integer -Z 6 vvar=-1
    -Z [ N ]
          Specially handled if set along with the -L flag.  Otherwise,
          similar to -R, except that leading zeros are used for padding
          instead of blanks if the first non-blank character is a digit.
          Numeric parameters are specially handled: they are always
          eligible for padding with zeroes, and the zeroes are inserted
          at an appropriate place in the output.
} But also with the negative not counting as part of
} of the padding?
I don't think you can, except by specifying a field width of 6.  Even
printf is going to treat the "-" as part of the field width.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author