Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!rpi!crdgw1!montnaro From: montnaro@spyder.crd.ge.com (Skip Montanaro) Newsgroups: comp.unix.questions Subject: Re: sorting (using sort/sed/awk/whatever) Message-ID: Date: 5 Aug 90 14:26:32 GMT References: <2943@mtung.ATT.COM> <13485@smoke.BRL.MIL> Sender: news@crdgw1.crd.ge.com Reply-To: montanaro@crdgw1.ge.com (Skip Montanaro) Organization: GE Corporate Research & Development, Schenectady, NY Lines: 31 In-reply-to: gwyn@smoke.BRL.MIL's message of 5 Aug 90 02:22:29 GMT In article <13485@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: In article <2943@mtung.ATT.COM> luke@mtung.ATT.COM (S. Luke Jones) writes: >Surely there's got to be an easy way to do this. Surely you jest. You're asking for an artificial intelligence program here. I don't know. The following short shell script seems to do what Luke wanted (cluster all the C++ groups together, regardless of their spot in the Usenet tree). Skip (montanaro@crdgw1.ge.com) #!/bin/sh newsrc=$1 options="`egrep '^options' $1`" echo $options egrep -v "^options" $1 | \ sed -e 's/\./ /g' -e 's/! /!/' -e 's/: /:/' | \ awk '{for (i=NF; i>0; i--) printf("%s\t", $i); printf("\n"); }' | \ sort | \ awk '{for (i=NF; i>0; i--) printf("%s\t", $i); printf("\n"); }' | \ sed -e 's/ /./g' -e 's/!/! /' -e 's/:/: /' | \ sed -e 's/\.$//' -- Skip (montanaro@crdgw1.ge.com)