printf will do what you want:
printf "%0.4d", 7;
prints out: 0007
and
printf "%0.*d", 4, 7;
prints out: 0007
of course, if you have a variable $len that has the length you want to
print you could just do
printf "%0.${len}d", 7;
and achieve the same results as
printf "%0.*d", $len, 7;
it is up to you which is more readable.
Good Luck!
Tanton Gibbs
-----Original Message-----
From: Javier Bellido
To: [EMAIL PROTECTED]
Sent: 8/19/2001 9:40 AM
Subject: formating numbers
Hi friends!
I need to print a data file in this way:
0001 kakkallsas........
0101 ksakslakskaks.....
0201 kkkaskaskkasa.....
How I get the numbers of the first column have the same lenght (4
numbers)?
And, It's possible assign the length of the numbers dinamically?
(if length of data < 999 then three numbers, if < 9999 four ...)
Thanks for your help
I'll hope you understand the question (english is not my mother
language)
Er_pelle
_____________________________________________________________________
Correo gratis con POP3, IMAP, en 18 idiomas...: http://www.mundomail.net
100 MB para tu web y mucho mas: http://www.vermail.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]