[comp.sys.ibm.pc] sorting multiple-line records

ray@ole.UUCP (Ray Berry) (07/07/90)

	I am looking for a sort utility that can handle records which span
over a (variable) number of lines.   I.e., one with a user-specifiable
record delimiter.  Does anybody know of such a sort? 
-- 
Ray Berry  kb7ht  uucp: ...ole!ray CIS: 73407,3152 /* "inquire within" */
Seattle Silicon Corp. 3075 112th Ave NE. Bellevue WA 98004 (206) 828-4422

cjp@beartrk.beartrack.com (CJ Pilzer) (07/07/90)

In article <1601@ole.UUCP>, ray@ole.UUCP (Ray Berry) writes:
> 
> 	I am looking for a sort utility that can handle records which span
> over a (variable) number of lines.   I.e., one with a user-specifiable
> record delimiter.  Does anybody know of such a sort?

The unix AWK program will process multiline records.   It can use any
delimiter you want.  There are versions of this program which will run
on dos.

One comes from Mortice Kerns Systems, Inc. UUCP:uunet!watmath!mks!inquiry
or Tel: 519-884-2251.  They are in Canada. 

Another is Polytron Corp. 503-645-1150 in Beaverton, OR.  I also 
think there is a PD or shareware version, but I don't know the name.

I think that the Programmer's Shop and other mail order places may
carry the programs.

You can see how to use it in The AWK Programming Language, by Aho,
Kernighan, & Weinberger.  They are the authors of the language, hence
AWK.  Look at pages 82-88.

-- cj

t-rayc@microsoft.UUCP (Raymond CHEN) (07/08/90)

Somebody else mentioned awk.  You might also want to consider 
Larry Wall's perl program, though it might be overkill for
this particular task.  It is distributed under the GNU guidelines,
and Diomidis Spinellis (dds@cc.ic.ac.uk) ported it to MS-DOS.

PD1:<MSDOS.PERL>PERL3.ZIP on SIMTEL20.

With perl, your task becomes a one-liner, assuming, say, that
records are separated by a blank line.

	perl -e "$/='';print sort <STDIN>;" <infile >outfile