bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The GNU Awk User’s Guide issue


From: arnold
Subject: Re: The GNU Awk User’s Guide issue
Date: Mon, 24 Jan 2022 00:24:03 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Thans for reporting as issue.

Mark Quinlan <markquinlan@live.com> wrote:

> https://www.gnu.org/software/gawk/manual/gawk.html#Foreword3
>
> The GNU Awk User’s Guide
>
> search for                                  the right-margin columns
>
> I am new but I have looked at this documentation several times. Shouldn't it 
> read > not < ?
>
> the text:
>
> Print the length of the longest line in data:
>
> expand data | awk '{ if (x < length($0)) x = length($0) }
>                    END { print "maximum line length is " x }'

This is correct as written. The variable 'x' starts out initialized
to zero.  Thus on the first line it will get set to the length of
that line. As each subsequent line is read, if x is less than the
length of the current line, it's updated. By the end, it contains the
length of the longest line in the input.

Thanks,

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]