San Diego State University

Technical Briefs

ROHAN help Files

----------------------------------------------------------------------

sort

The sort filter can either alphabetize all of the lines in a specified file according to the first letter in each line or it can merge files together into one sorted file. The syntax to sort a file is:

rohan% sort  filename

The syntax to merge sorted files is:

rohan% sort  -m  file1  file2  file3  >  newfilename

It is almost always necessary to use an option when using sort because the computer sorts data in ascending order according to the ASCII code. This means that the number 1 will always come before the number 9 and the uppercase letters will always come before lowercase letters, etc. Using the sort options forces the computer to sort the items correctly.

There are several options that can be used with sort to modify it's function. They are:

-o - creates a new file which contains the sorted information

-f - treats capital and lowercase letters the same

-n - sorts numbers correctly

-r - sorts in reverse order

-m - merges files that have been sorted.

-u - deletes duplicate lines in the sorted file

-d - ignores punctuation while sorting

The syntax when using options is:

rohan% sort  filename  -option  newfile

----------------------------------------------------------------------


BACK ROHAN Help Index | Academic Computing Handouts, Manuals, and Help Files