Can someone show, how to use awk command to identify the longest line in a text file.
Thanks
To print the longest line:
awk 'length > m { m = length; a = $0 } END { print a }' input-file
To simply identify the longest line by line number:
awk 'length > m { m = length; a = NR } END { print a }' input-file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With