next up previous contents
Next: Displaying the last few Up: Other useful commands Previous: Using find for useful   Contents

Sorting files

The command sort <filenames> sorts files alphabetically by line. Sort considers each line as a record with space-separated fields. By default the first field is used to sort the file. The sort command has many options: sorting numerically, sorting in reverse order, sorting on fields within the line etc. Please check the man page for more options.

Here are some common options:

sort -r file1   reverse normal order
sort -n         sort in numeric order
sort -rn        sort in reverse numeric order
sort -f         fold upper and lower case together
sort +n         sort starting at n+1st field



Amit Jain 2009-08-23