Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!spool.mu.edu!uwm.edu!linac!palkovic From: palkovic@tomato.fnal.gov (John Palkovic) Newsgroups: comp.unix.shell Subject: How can I optimize this script? Message-ID: Date: 1 Mar 91 17:22:39 GMT Sender: usenet@linac.fnal.gov Reply-To: palkovic@linac.fnal.gov Distribution: na Organization: Bob's School of Quantum Mechanics Lines: 36 I posted this script yesterday (<9Y`#-6-@linac.fnal.gov> in news.software.b) to remove old news floods (newly arrived articles with old Date: headers): #!/bin/sh # # Old.rm. Trash new news articles with old Date: headers. # J. Palkovic 2/28/91 # # You may need to change this next line: PATH=/usr/lib/newsbin:/usr/local/bin:/usr/bin TODAY="`date`" TODAY=`getdate "$TODAY"` LIMIT=`expr $TODAY - 1209600` cd /usr/spool/news find `ls |egrep -v '\.'` -mtime -7 -name '[0-9]*' -type f -print |( while read f do DATE=`header -f Date $f` THEN=`getdate "$DATE" 2>/dev/null` if test "$THEN" then test $THEN -lt $LIMIT && rm -f $f fi done ) Header is a C program that extracts header fields, written by Chip Salzenberg (see above mentioned post for source to header). The question I have for all you comp.unix.shell gurus is: how can I speed this script up? It took more than two hours to run on our 150+ MB news spool. I have some ideas, but would like to hear from you. -John -- palkovic@linac.fnal.gov || {tellab5,royko,simon}!linac!palkovic