Sep 9, 2003 #1 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?
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?
Sep 9, 2003 #2 vgersh99 Programmer Jul 27, 2000 2,146 US BEGIN { width=50 } { tmp = (length($0) < width) ? sprintf("%-50s", $0) : $0; print tmp; } vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
BEGIN { width=50 } { tmp = (length($0) < width) ? sprintf("%-50s", $0) : $0; print tmp; } vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Sep 9, 2003 1 #3 CaKiwi Programmer Apr 8, 2001 1,294 US { printf ("%-50s\n",$0) } should be good enough. If the line is longer than 50 characters they will all be printed out. CaKiwi "I love mankind, it's people I can't stand" - Linus Van Pelt Upvote 0 Downvote
{ printf ("%-50s\n",$0) } should be good enough. If the line is longer than 50 characters they will all be printed out. CaKiwi "I love mankind, it's people I can't stand" - Linus Van Pelt
Sep 9, 2003 #4 vgersh99 Programmer Jul 27, 2000 2,146 US good catch! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
good catch! vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Sep 9, 2003 Thread starter #5 rufflocks Technical User Jun 29, 2001 26 US Thank You. That worked. Upvote 0 Downvote