#!/bin/sed -f # Sort, partition, and number a list of names in only 14 sed commands. # By Greg Ubben, 14 Nov 1996 # # Use with -n option to prevent a trailing blank line. # Assumes no control characters, even though the sort handles tabs. # Sed insertion sort by Greg Ubben, 26 April 1989. All rights reserved. # Note that the code contains some unprintable Ctrl-A and Tab characters. # The \(\(.\)\) have been unnested to allow for some brain-damaged seds. # Some overlap with next; s:/:/.: the last command for a stand-alone sort. # Greg's e-mail note to seders list: # The code contains a few control characters, so I've included a # "readable" version immediately below with the Ctrl-A's and Tabs # changed to ^As and ^Is, followed by a uuencoded copy that you can use # if you want to run it. G 1s/\n/&&^A^I !"#$%\&'()*+,-.\/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~/ s/\([^I -~]*\)\(\n\)/\2\1^A/ s/^\(.[^I -~]*\)\([^I -~]\)\([^A^I -~]*\)\(.*\1\)\([^A^I -~]\)\([^A^I -~]*\)\(.*\n.*\5[^I -~]*\2[ -~]*\)$/\4\5\6\1\2\3\7/ h $!d s/^A//g s/\(.*\)\n.*/\1/ # Output, adding a blank line between sections and numbering each section. # The do-nothing X* below is needed on the SunOS 4.1 sed to work around a # RE bug that occurs when a non-null c* closure precedes a null \n recall. : loop s/\([0-9]*\)[ -~]*\n/\1;9876543210990090 / s/\([0-8]\{0,1\}\)\(9*\);[^1]*\(.\)\1[0-9]*X*\2\(0*\)[^ ]*/\3\4/ P /^[0-9]* \(.\).*\n\1/ !s/[ -~]*// /^\n/P /./b loop # begin 755 impossible.sed # M(R$O8FEN+W-E9" M9@HC("!3;W)T+"!P87)T:71I;VXL(&%N9"!N=6UB97(@ # M82!L:7-T(&]F(&YA;65S(&EN(&]N;'D@,30@2!'2!' # M7V!A8F-D969G # M:&EJ:VQM;F]P<7)S='5V=WAY>GM\?7XO"G,O7"A;"2 M?ETJ7"E<*%QN7"DO # M7#)<,0$O"G,O7EPH+EL)("U^72I<*5PH6PD@+7Y=7"E<*%L!"2 M?ETJ7"E< # M*"XJ7#%<*5PH6P$)("U^75PI7"A; 0D@+7Y=*EPI7"@N*EQN+BI<-5L)("U^ # M72I<,EL@+7Y=*EPI)"]<-%PU7#9<,5PR7#-<-R\*: HD(60*S L,5Q]7"E< # M*#DJ7"D[6UXQ72I<*"Y<*5PQ6S M.5TJ6"I<,EPH,"I<*5M>(%TJ+UPS7#0O # M"@E0"@DO7ELP+3E=*B!<*"Y<*2XJ7&Y<,2\@(7,O6R M?ETJ+R\*"2]>7&XO # ,4 HO+B]B(&QO;W * # # end