I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).
AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC
MY * A02 RESALE 6990788000 Y PERMANENT PLACEMENT FEES-CWS
CZ * A04 RESALE 6990788000 Y PERMANENT PLACEMENT FEES-BUS SVCS
GH * A06 EXPENSE 6990375009 TAXES EXPENSES-FROM WWER
CZ * A04 RESALE 6990788000 Y PERMANENT PLACEMENT FEES-BUS SVCS MAINTENANCE PAYMENT
I'm using this line of code to achieve this.
awk '{printf "%-99s\n",$0}' $stagedir/$1_SAVE > $workdir/$1_SAVE
However, we are having problems when the length of a record within the file exceeds 100 characters. The receiving program that processes my output file is unable to parse it correctly.
I was asked to truncate the records first, get the first 99-characters of each line, and then add the line feed character at the end of the line.
How do I do this? Please help me. Thank you.