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

adding trailing spaces 1

Status
Not open for further replies.

rufflocks

Technical User
Jun 29, 2001
26
US
Input file is variable length.
If record length is not 50 bytes I want to add trailing spaces to make the record 50 bytes.

Any suggestions?
 
BEGIN {
width=50
}
{
tmp = (length($0) < width) ? sprintf(&quot;%-50s&quot;, $0) : $0;
print tmp;
}


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
{
printf (&quot;%-50s\n&quot;,$0)
}

should be good enough. If the line is longer than 50 characters they will all be printed out.

CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
good catch!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top