From: Gary Williamson on
In a shell script I want to echo out some values whcih are not necessarily as wide as they should be.

For example a value of 7 should be display as a field of width 4 with left padded zeros "0":

0007

How can I accomplish this?

Gary
From: Bill Marcum on
["Followup-To:" header set to comp.unix.shell.]
On 2008-06-17, Gary Williamson <garywill(a)usca.edu> wrote:
>
>
> In a shell script I want to echo out some values whcih are not
> necessarily as wide as they should be.
>
> For example a value of 7 should be display as a field of width 4 with
> left padded zeros "0":
>
> 0007
>
> How can I accomplish this?
>
> Gary

printf "%04d\n" 7