home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 35.23 Rotating Text Chapter 36 Next: 36.2 Sort Fields: How sort Sorts

36. Sorting

36.1 Putting Things in Order

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:





  • Article 36.2 describes how to select individual fields from a line for sort to operate on.

  • Article 36.3 describes how to change the field delimiter from "white space" to some other character.

  • Article 36.4 describes the kinds of problems that you can encounter if fields are delimited by white space.

  • Article 36.5 clarifies the distinctions between alphabetic and numeric sorting.

  • Article 36.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 (article 36.7 ).

  • Sort lines by how long they are (article 36.8 ).

  • Sort a list of names by last name, whether or not there's a middle name as well (article 36.9 ).


Previous: 35.23 Rotating Text UNIX Power Tools Next: 36.2 Sort Fields: How sort Sorts
35.23 Rotating Text Book Index 36.2 Sort Fields: How sort Sorts

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System