Posted On 2007-04-25 by FortyPoundHead
Keywords: Command Reference
Tags: Windows Commandline Windows
Views: 1510

Sort will accept a redirected or piped file input and TYPE the file, sorted line by line.

SORT [options]

Options /R : Reverse sort order (Z to A, 9 to 0)
/+n : Sort the file ignoring the first ''n'' characters in each row.
The default is to sort using all the chars in each row.

/L[OCALE] locale

Override the system default locale with
The "C" locale yields a faster
collating sequence.
The sort is always case insensitive.

/M[EMORY] kilobytes

The amount of RAM to use for the sort.
The best performance is usually achieved by
not specifying a memory size.

SORT will only create a temporary file
when required by limitations in available memory.

/REC[ORD_MAXIMUM] characters

The maximum number of characters in a row or record
(default 4096, maximum 65535)


The file to be sorted.
If not specified, the standard input is sorted.
Specifying an input file is faster than
redirecting the same file as standard input.

/T[EMPORARY] [drive:][path]

The path of the directory to hold
SORT''s working storage, in case the data
does not fit in RAM. The default is %temp%

/O[UTPUT] [drive:][pathname]

The file where the sorted input is to be stored.
If not specified, the data is written to standard output.
Specifying an output file is faster than redirecting
standard output to a file.
Windows NT 4 does not support any of the above options other than /R and +n

Redirecting a file into SORT

SORT < pathname

Piping a command into SORT

command | SORT

Piping the output from SORT into a file

command | SORT > pathname2

SORT < pathname > pathname2

Piping the output from SORT and appending to an existing file

command | SORT >> pathname2

SORT < pathname >> pathname2

About the Author

has posted a total of 1974 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links