Longest line in a file

I'm looking for a simple way to find the length of the longest line in a file. Ideally, it would be a simple bash shell command instead of a script.


Solution 1:

Using wc (GNU coreutils) 7.4:

wc -L filename

gives:

101 filename

Solution 2:

awk '{print length, $0}' Input_file |sort -nr|head -1

For reference : Finding the longest line in a file