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.
Variation on the theme.
This one will show all lines having the length of the longest line found in the file, retaining the order they appear in the source.
FILE=myfile grep `tr -c "\n" "." < $FILE | sort | tail -1` $FILE
So myfile
x mn xyz 123 abc
will give
xyz 123 abc