Summary Box
Sorting a file under Unix is easy, right? Of course it is, if all you want
to do is sort a list of single words, or sort lines starting with the first
character in the line. But if you want to do more than that, there's a lot
more to the sort command than typing
sort
filename
:
Section 22.2 describes how to select individual fields from a line for sort to operate on.
Section 22.3 describes how to change the field delimiter from whitespace to some other character.
Section 22.4 describes the kinds of problems that you can encounter if fields are delimited by whitespace.
Section 22.5 clarifies the distinctions between alphabetic and numeric sorting.
Section 22.6 gives miscellaneous hints about useful sort options.
But learning the mechanics of sort isn't the end of the story. Like most of the other things you'll find in the Unix toolbox, sort is even more powerful when it's used with other programs. For example, you can:
Sort paragraphs or other multiline entries.
Sort lines by how long they are (Section 22.7).
Sort a list of names by last name, whether or not there's a middle name as well (Section 22.8).
— TOR