Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left padding 1

Status
Not open for further replies.

maxtektips6

Programmer
Joined
Jan 25, 2007
Messages
17
Location
NL
Hi,

Is there any easy way to do left padding on an unknown length of strings ?

examples:

2856 -> 0000002856
12 -> 0000000012
 
Format(yourVariable, "0000000000")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. This seems to work:

Code:
awk '{ printf "%010d\n",$1}'
 
OOps, sorry for the the bad previous reply.
In a ksh-like shell you may use the typeset builtin command:
typeset -Z10 a
a=12
echo $a
0000000012

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top