It is difficult reading this code because you didn't put it inside a CODE block.
The line blank = blank " " doesn't look right.
I thought I had an idea of locating the last space before N and print the line like:
Code:
printf "%s\\\n", substr($0,i,m-1)
but when you take tabs into consideration, things are complicated. What do you use for a tabstop width? I don't think that length($0) takes tabs into consideration either so it doesn't look like a simple adjustment of the loop.
Quote:
Originally Posted by Gawk: Effective Awk Programming
• Print the length of the longest line in ‘data’:
expand data | awk ’{ if (x < length()) x = length() }
END { print "maximum line length is " x }’
The input is processed by the expand utility to change tabs into spaces, so the widths
compared are actually the right-margin columns.
|
They pre-expanded the text before processing with awk.
I created a pdf version of the info manual from the texinfo source in the source gawk package. I highly recommend you do the same.