Name

sort — \windows\system32\sort.exe

Synopsis

The sort command sorts text on a line-by-line basis. sort is often used in conjunction with either pipes or output redirection (see the beginning of this chapter), wherein you can sort the output of another command. sort takes the following options:

sort [/r] [/+n] [/m kilobytes] [/rec recordbytes]
   [/t [tempdir]] [/o outputfilename] [filename]

Option

Description

/r

Reverses the sort order; that is, sorts Z to A, then 9 to 0.

/+ n

Sorts the file according to characters in column n.

/m kilobytes

Specifies amount of main memory to allocate for the sort operation, in kilobytes (160 kb being the minimum).

/rec recordbytes

Specifies the maximum number of characters on a line (in a record); the default is 4096, and the maximum is 65,535.

/t tempdir

Specifies the location of the folder used to store temporary files in case the data does not fit in main memory (see /m).

/o outputfilename

Specifies a file where the output is to be stored. If not specified, the sorted data is displayed at the prompt. Using the /o option is faster than redirecting output (with the > symbol).

filename

The name (and optionally, full path) of the file to sort.

Examples

dir | sort
sort /o results.txt data.txt
sort data.txt > results.txt
type data.txt | sort > results.txt

Get Windows XP Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.