sorting (using sort/sed/awk/whatever)
Skip Montanaro
montnaro at spyder.crd.ge.com
Mon Aug 6 00:26:32 AEST 1990
In article <13485 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
In article <2943 at mtung.ATT.COM> luke at 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 at 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 at crdgw1.ge.com)
More information about the Comp.unix.questions
mailing list