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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting with sed 1

Status
Not open for further replies.
Jul 28, 2004
726
BE
Hi all,

I've got following lines in a file :
hdisk1 543 543 0 00..00..00..00..543
hdisk2 543 500 43 00..00..00..00..543

and I would like to get them in this format, using sed ( or awk )
hdisk1 543 543 000 000..000..000..000..543
hdisk2 543 500 043 000..000..000..000..543

Does anyone see a way of getting that kind of output?

thx in advance

greetingz,

RMGBelgium
 
In the awk man page take a look at the printf function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try this awk script

{
n=split ($5,a,/\.\./)
printf("%s %03d %03d %03d ",$1,$2,$3,$4)
printf("%03d",a[1])
for (j=2;j<=n;j++)
printf("..%03d",a[j])
print ""
}

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top