Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sort(CMD) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 sort(CMD)                       19 June 1992                       sort(CMD)


 Name

    sort - read input, sort data, and write the results to screen, a file, or
    another device

 Syntax


    sort [/r] [/+n] [<] [drive1:][path1]filename1
    [> [drive2:][path2]filename2]

    [command |] sort [/r] [/+n] [> [drive2:][path2]filename2]


 Description

    sort acts as a filter, reading characters in a specified column and rear-
    ranging them in ascending or descending order.

 Parameters


    [drive1:][path1]filename1
              Specifies the location and name of the file whose data you want
              to sort.

    [[drive2:][path2]filename2
              Specifies the location and name of a file in which the sorted
              output is to be stored.

    command   Specifies a command whose output is the data you want to sort.


 Switches


        /r    Reverses the order of the sorting operation; that is, sorts
              from Z to A, and then from 9 to 0.

        /+n   Sorts the file according to the character in column n. If you
              do not use this switch, the sort command sorts data according
              to the characters in column 1.


 Notes


    Specifying a source

    Unless you specify the command or filename parameter, sort acts as a
    filter and takes input from the MS-DOS standard input (usually from the
    keyboard, from a pipe, or from a file).

    Using redirection symbols with sort

    You can use the pipe (|) or the less-than sign (<) to direct data through
    the sort command from command or filename. If you want to display the in-
    formation one screen at a time or direct the information to a file, you
    can also specify the more command or a filename.  You can use the
    greater-than sign (>) to direct the sorted output to a file.

    Before using a pipe for redirection, you should set the TEMP environment
    variable in your AUTOEXEC.BAT file.

    Collating sequence

    The sort program uses the collating-sequence table corresponding to the
    country code and code-page settings.  Characters greater than ASCII code
    127 are sorted based on information in the COUNTRY.SYS file or in an
    alternate file specified by the country command in your CONFIG.SYS file.

    Uppercase vs. lowercase

    sort does not distinguish between uppercase and lowercase letters.

    Limits on file size

    The sort command can handle files as large as 64K.

 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 CtrlZ, and then press
    Enter.  The sort command displays the text you typed, sorted alphabeti-
    cally.  You could also redirect sorted keyboard input to a file.

 Related command

    For information about displaying information one screen at a time, see
    the more(CMD) command.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026