Disksort

PURPOSE    OPERATION    COMMAND LINES    OPTIONS    RELATED PROGRAMS


Author: Dan Mares, dm @ maresware . com (you will be asked for e-mail address confirmation)
Portions Copyright © 1998-2023 by Dan Mares and Mares and Company, LLC
Phone: 678-427-3275

top

Purpose

One liner: Sorts a file containing fixed length records on a key field

From my history in dealing with gigantic mainframe data records, I wrote almost all of maresware software so it is capable of outputing fixed length records. Disksort was then designed to be able to sort fixed length records on specified key fields within the record. If you have a data file that is made up of fixed length records, disksort will allow you sort on a key field without loading into a spreadsheet or data base and then performing a sort. The outupt of disksort can then be further processed by any number of other (maresware and other) programs. More specifically, after you have sorted the data, you might use the search.exe program to search out records within the data file which meet your requirements.

If your records are not fixed length, but are delimeted with a pipe or other truly reliable delimiter (not CSV) then you can use the maresware PIPEFIX program to make the records fixed length, which can then be fed to disksort. All of this is easily accomplished in batch files.


top

Operation

ERROR MESSAGES:

If you should experience difficultiy in sorting files and receive error messages please write them down and contact Mares and Company. These error messages are generated by the sort routine that was linked into the program, and we have no control over them. However, we can perhaps evaluate them, and help you with your problem.

install=path\...\share.exe


top

Command Lines

C:> disksort input output -[options[rplu]]
Item 1:Program name
Item 2:Input file name
Item 3:Output file name
Item 4:Options -[rpldauU]
C:> disksort infile outfile -r 40 -p 10 -l 5 -p 20 -l 4 -d

The sort fields are #1 position 10, and length 5, #2 position 20, and length 4

C:> disksort infile outfile -r 64 -p 1 -l 8 -i 1 8
sorts on 1st 8 characters and produces only those records with multiple occurances of the key.

C:> disksort infile.* outfile -r 64 -p 1 -l 8
sorts/merges all input files of input.* filespec to output file outfile

C:> disksort infile outfile -r 64 -p 1 -l 8 -u
sorts input and eliminates duplicate records

C:> disksort infile1 infile2 outfile -r 64 -p 1 -l 8 -m
merge infile1 and infile2 to outfile (inputs must already be sorted)

You can have up to 10 sort fields. Place them in the proper the proper order in the command line.

If the descending -d option is used it should be paired with and immediately follow the associated -pl option pair for that particular sort key.

Example of the field section of the command line:

-p 0 -l 5 -p 10 -l 5 -d

(first field) (second field) means the second sort field (position 10, length 5) is to be a descending sort. The first sort field is, by default, ascending sort.

DO NOT PLACE THE -a or -d OPTIONS BY THEMSELVES. Unexpected results will occur. THEY MUST FOLLOW THE -p -l pair.


top

Options

-a     (a)scending sort [DEFAULT] [must be paired and follow the -pl option].

-d     (d)escending sort [if used, must be paired and follow the -pl option].

-r + #     Next argument is record length.

-p + #     Next argument is displacement to "position" of the sort key. All displacements begin at 1, not 0.

-l +    Next argument is length of the sort key.

-m    Merge input files only. (Inputs must already be sorted.)

-i # ##    The i option is used to include in the output file only those records which have DUPLICATE sort keys as identified by the # and ## items. It will include all the records which contain the duplicate keys.

Replace the # with the position of the key field and the ## with its length.The # and ## should be identical to the field identified in the -p and -l options. See the sample below.

-u    During sort or merge eliminate duplicate records, based on 1st sort/merge field.

-U # ##   Remove duplicates during a sort or merge on field designated by # (displacement) and ## (length).

IMPORTANT NOTE ON THE -p and -l OPTIONS:

The position and length options are to be used in paired sequences. By this I mean that after a -p or -l you must then specify the appropriate displacement position of the sort key or length of the key. Remember, the first character of the record is counted as displacement 1-- not zero.

For every -p there must be a matching -l or you will get an error message and the program aborts.


Related Programs

OPT-TECH SORT, Commercial program.

RPSORT: Shareware program available on the internet.

top