> DOS 中文参考手册 > sort

SORT

(sort)


SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]

  [[drive1:][path1]filename1] [/T [drive2:][path2]]

  [/O [drive3:][path3]filename3]

  /+n                         指定开始每个比较的字符号码 n。/+3 说明每个比较应从每行的第三个字符开始。少于 n 个字符的行排在其他行之前。按默认值,从每行的第一个字符开始比较。

  /L[OCALE] locale            用指定的区域设置替代系统默认区域设置。

                              ""C"" 区域设置产生最快的排序顺序并且是当前的唯一其他选择。排序总是不分大小写的。

  /M[EMORY] kilobytes         指定用于排序的主内存量,单位为 KB。

                              最小内存量总是 160 KB。如果指定内存大小,无论主内存的可用量是多少,指定的内存量会全部用于排序。

                              要取得最佳性能,通常不指定内存大小。按默认值,如果达到默认最大内存值,排序会一次完成(非临时文件);否则,排序会分两次完成(没有完全排序的数据存储在临时文件中);用于排序和合并的内存量相等。如果输入和输出都是文件, 默认最大内存量为可用主内存的 90%;

                              否则,为主内存的 45%。

  /REC[ORD_MAXIMUM] characters 指定记录中的最大字符数量(默认值为 4096,最大值为 65535)。

  /R[EVERSE]                  颠倒排序顺序,即,从 Z 到 A,再从 9 到 0。

  [drive1:][path1]filename1   指定要排序的文件。如果没有指定,则排序标准输入。指定输入文件比将同一个文件重定向为标准输入快。

  /T[EMPORARY]

    [drive2:][path2]          指定保留排序工作存储的目录路径,以防主内存无法容纳数据。默认值是使用系统临时目录。

  /O[UTPUT]

    [drive3:][path3]filename3 指定在哪个文件中储存经过排序的输入。

                              如果没有指定,数据会被写入标准输出。指定输出文件比将标准输出重定向到同一个文件快。

★★★★★实例★★★★★:

以下命令读文件EXPENSES.TXT,以反向次序排序,并在屏幕上显示:

sort /r < expenses.txt

若要在一个名为MAILLST.TXT的大文件中查找正文“Jones”要对查找结果排序,则可使用管道(|)将find命令的输出重定向到SORT命令,如下例所示:

find "jones" maillst.txt | sort

此命令产生包含指定正文的行排序列表。

要排序键盘输入并在屏幕上按字母顺序显示结果,可使用无参数的SORT命令,如下所示:

SORT

然后输入要排序的正文,在每一行的结尾按ENTER。输入完毕后按按CTRL+Z和ENTER。SORT命令显示输入的正文,并按字母顺序排序。可将排序后的键盘输入重定向到文件。


SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]

  [[drive1:][path1]filename1] [/T [drive2:][path2]]

  [/O [drive3:][path3]filename3]

  /+n                         Specifies the character number, n, to begin each comparison.  /+3 indicates that each comparison should begin at the 3rd character in each line.  Lines with fewer than n characters collate before other lines.

                              By default comparisons start at the first character in each line.

  /L[OCALE] locale            Overrides the system default locale with the specified one.  The ""C"" locale yields the fastest collating sequence and is currently the only alternative.  The sort is always case insensitive.

  /M[EMORY] kilobytes         Specifies amount of main memory to use for the sort, in kilobytes.  The memory size is always constrained to be a minimum of 160 kilobytes.  If the memory size is specified the exact amount will be used for the sort,regardless of how much main memory is available.

                              The best performance is usually achieved by

SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]  [[drive1:][path1]filename1] [/T [drive2:][path2]]

  [/O [drive3:][path3]filename3]

  /+n                         Specifies the character number, n, to begin each comparison.  /+3 indicates that each comparison should begin at the 3rd character in each line.  Lines with fewer than n characters collate before other lines.By default comparisons start at the first character in each line.

  /L[OCALE] locale            Overrides the system default locale with the specified one.  The ""C"" locale yields the fastest collating sequence and is currently the only alternative.  The sort is always case insensitive.

  /M[EMORY] kilobytes         Specifies amount of main memory to use for the sort, in kilobytes.  The memory size is always constrained to be a minimum of 160 kilobytes.  If the memory size is specified the exact amount will be used for the sort, regardless of how much main memory is available.

                              The best performance is usually achieved by not specifying a memory size.  By default the sort will be done with one pass (no temporary file) if it fits in the default maximum memory size, otherwise the sort will be done in two passes (with the partially sorted data being stored in a temporary file) such that the amounts of memory used for both the sort and merge passes are equal.  The default maximum memory size is 90% of available main memory if both the input and output are files, and 45% of main memory otherwise.

  /REC[ORD_MAXIMUM] characters Specifies the maximum number of characters  in a record (default 4096, maximum 65535).

  /R[EVERSE]                  Reverses the sort order; that is,sorts Z to A, then 9 to 0.

  [drive1:][path1]filename1   Specifies the file to be sorted.  If not specified, the standard input is sorted.

                              Specifying the input file is faster than redirecting the same file as standard input.

  /T[EMPORARY]

    [drive2:][path2]          Specifies the path of the directory to hold the sort's working storage, in case the data does not fit in main memory.  The default is to use the system temporary directory.

  /O[UTPUT]

    [drive3:][path3]filename3 Specifies the file where the sorted input is to be stored.  If not specified, the data is written to the standard output.   Specifying the output file is faster than redirecting standard output to the same file.


上一篇:
下一篇: