Hi folks
I have - with your help - some code which shortens lines in a file to a specified length MaxLen:
k = length
while ( k > MaxLen ) {
for (m = MaxLen; m > 0; m--) if (substr( $0, m, 1) == " ") break
if ( m == 0 ) m = MaxLen
print substr($0, 1, m) > Output...
CaKiwi - thanks a lot, it works like a charm !
Less code, more functionality !
Am I correctly understanding that the for-loop targets only the statement "if (substr(...) break" ?
Did not know that you can assign a new value to $0 - guess I have learned somic tonight !
Thanks
Chris
I have files with long text strings that need to be cut to a certain length. This is the code I have done so far:
10: MaxLen = 60 # desired length of string
20: LineLen = length($0)
30: if ( length($0) > MaxLen ) { # If $0 >...
Hi
I am new to AWK, on Windows, and need to re-format textfiles like this one:
:54:any text on one line
:86:this text field co
vers two lines or ev
en more lines
:54:here is another text on one line
The result should show all lines beginning with :xx: ; the
record starting with :86: should...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.