03/29/76 sort, merge Syntax: sort input_specs output_spec {-control_args} merge input_specs output_spec {-control_args} Function: Sort (Merge) one or more files according to the values of one or more key fields. This info file applies to both the sort and the merge; see the section "Differences Between Sort and Merge". Arguments: input_specs Specify each input file (up to 10) as - -if pathname Pathname in Storage System, or -ids "attach_desc" Attach description. output_spec Specify just one output file as - -of pathname Pathname in Storage System, or -of -replace Replace input file by output file, or -ods "attach_desc" Attach description. Control arguments: -ci Sort (Merge) Description input via terminal, or -sd pathname Pathname of Sort Description (sort command only), or -md pathname Pathname of Merge Description (merge command only). -td pathname Pathname of directory to contain work files; default is user's process directory (sort command only). -file_size f Estimated total amount of data to be sorted, in millions of bytes (sort command only). Examples: 1) sort -ci -if in -of -rp Sort Description from user's terminal; input file is named in; output file will replace input file. Input. The Sort requests the Sort Description. keys: char(10) 0; The single key is a character string whose length is 10 bytes, and which starts at the first byte of the record (word 0, bit 0). . A line consisting of "." terminates the Sort Description from a terminal. 2) sort -sd sort_desc -td >udd>pool Sort Description entered from a segment; work files will be contained in the directory >udd>pool; no input or output file is named. Assume the segment sort_desc contains - key: bin(17) 1; The key is fixed binary aligned, and occupies the second word of the record. exits: input_file user$input Input_file exit procedure is user$input. output_file user$output; Output_file exit procedure is user$output. 3) sort -ids "tape_ansi_ V" -ods "record_stream_ -target vfile_ b" -ci Input file specified by attach description for a magnetic tape in ANSI format; output file specified to be unstructured (the Sort's record output will be transformed into stream output). 4) merge -md merge_desc -if a.in -if b.in -of =.out Merge Description entered from a segment; input files are named a.in and b.in; output file will be named b.out. Syntax of the Sort (Merge) Description: keys: ... ; exits: ... ; If -ci is used, the additional line "." terminates input. There may be up to 32 keys described. Syntax of a Key Description: () [()] [descending] where - Data type of a key field; can be - char, bit, fixed bin, float bin, dec, float dec. Length of the key field (in decimal), in units appropriate to the data type. Offset in words from the beginning of the record. Words are numbered (in decimal) starting at 0. Offset in bits from the beginning of the word. Bits are numbered (in decimal) starting at 0. descending Rank in descending order for this key field. Syntax of an Exit Description: where - Name of the exit point - input_file (sort command only) output_file (sort command only) compare input_record (sort command only output_record Name of the entry point of the user procedure, in the same form as a command name. Writing an Exit Procedure: See the MPM descriptions of the subroutines sort_ and merge_ for a complete description of how to write a user exit procedure; or type "help sort_" or "help merge_" for a summary. Functions: Sort or merge one or more files of records which are not ordered, to create a new file of ordered (or "ranked") records. Files Supported: An input or output file can be specified either by a pathname or by an attach description. Its organization must be structured (record I/O is used). Records can be either fixed length or variable length. If the user names an input file or an output file, it must be in the Multics Storage System. (It can be either a segment or a multisegment file.) If the user supplies an attach description, any I/O module available at the installation can be used, provided it supports sequential record I/O. Input: The user can specify up to 10 input files. The organization can be either sequential or indexed. Alternatively, the user must name an input_file exit procedure, which is then responsible for releasing records to the Sort. Output: The user can specify one output file. The organization must be sequential. Alternatively, the user must name an output_file exit procedure, which is then responsible for retrieving records (ranked by the Sort) from the Sort. Sort Description: In addition to the arguments to the sort or merge command, a Sort (Merge) Description is necessary to specialize the Sort (Merge) for a particular execution. It can be supplied either via the user's terminal, or via a segment. A Sort Description can include the following statements - keys Specifies key fields, used for ranking records. exits Names user-written exit procedures. Keys Statement: Up to 32 key fields can be specified. Use any PL/I data type - except varying string, complex, or pictured. Ordering can be ascending, descending, or mixed. The original order of records with equal keys is preserved. If key fields are not described via the keys statement, then the user must name a compare exit procedure. Exits Statement: User-written "exit procedures" can be supplied at specific points in the sorting process. The following exits are supported: input_file Reads input file, releases records to the sort. output_file Receives records in ranked order, writes output file. compare Compares two records, decides which ranks first. input_record Process each input record (delete, insert, or alter). output_record Process each output record (delete, insert, alter, or summarize data). Differences Between Sort and Merge: The merge command has the following restrictions - 1) -replace cannot be used for the output file. 2) -td and -file_size cannot be specified. 3) The following exit points are not provided - input_file output_file input_record ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group BULL including BULL HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell BULL Inc., Groupe BULL and BULL HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, BULL or BULL HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by BULL HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved