36.8 lensort: Sort Lines by LengthA nice little script to sort lines from shortest to longest can be handy when you're writing and want to find your big words:
Once I used it to sort a list of pathnames:
The script uses awk (33.11 ) to print each line's length, followed by the original line. Next, sort sorts the lengths numerically (36.5 ) . Then sed (34.24 ) strips off the lengths and the spaces - and prints the lines:
(Some awk
s require a semicolon after the first curly bracket - that
is, - |
|