SORT--Examples
The following command reads the file EXPENSES.TXT, sorts it in reverse
order, and displays it on your screen:
sort /r < expenses.txt
Suppose you want to search a large file named MAILLST.TXT for the text
"Jones", and suppose you want to sort the results of the search. To do this,
use the pipe (|) to direct the output of a FIND command to the SORT command,
as shown in the following example:
find "jones" maillst.txt | sort
The command produces a sorted list of lines that contain the specified
text.
To sort keyboard input and display the results alphabetically on the screen,
you can first use the SORT command with no parameters, as the following
example shows:
SORT
Then type the text you want sorted, pressing ENTER at the end of each line.
When you have finished typing text, press CTRL+Z, and then press ENTER. The
SORT command displays the text you typed, sorted alphabetically. You could
also redirect sorted keyboard input to a file.
|