Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Need a free command-line utility to sort a big flat file (>10Mb) on fields at specific position.

A few years ago, I was using something called bigsort.exe on OS/2 but I can't find something similar.

share|improve this question
CMSort (32-bit) is good. RPSort (16-bit no Win7) is GREAT! – user160411 Sep 20 '12 at 16:00
Yep, CMSort is good ( ) – realhowto Oct 29 '12 at 21:05
up vote 2 down vote accepted

Windows comes with a sort utility:

C:\Documents and Settings\Administrator>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

                              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.
    [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.
    [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.

although the ported version (GNU Win32) is much more flexible.

share|improve this answer
There's an awful lot Windows can do from the command line, and I'm ashamed to admit that I hardly ever use it. Thanks for the reminder. – ChrisF Dec 10 '09 at 23:22
For sure! And it's only getting better in newer versions of Windows – John T Dec 10 '09 at 23:27
You can't specified the sorted fields like field1 pos 1-9 and field pos 18-22 – realhowto Dec 11 '09 at 0:14
That's why I stated that the GNU Win32 version is more flexible. It's a port of the GNU sort utility. The best the Windows sort utility can do is start on the character you specify. – John T Dec 11 '09 at 0:33
You're right, GNU sort looks good. Thanks. – realhowto Dec 11 '09 at 12:11

For completeness, Cygwin contains sort, and the usual suspects of GNU command line utilities (and much more).

GNU Win32 sort should be similar, since they're coming from the same sources (though probably have different versions at any given time).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .