Hi All,
I am studying the AWK tutorial and found this line of code and unable to understand correctly.
Q - Print the length of the longest input line:
awk '{ if (length($0) > max) max = length($0) }
END { print max }' data
As per my understanding, the length function reading the first line and comparing with max, then max is assigned to first line.
It compares all lines and print max at last. Is my understanding correct. One more question i have is, can we assign a value after comparing. I generally know we have to assign values before any comparison. Please some one explain this.
Thanks, Nagesh