How can I optimize this script?
John Palkovic
palkovic at tomato.fnal.gov
Sat Mar 2 04:22:39 AEST 1991
I posted this script yesterday (<9Y`#-6- at 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 at linac.fnal.gov || {tellab5,royko,simon}!linac!palkovic
More information about the Comp.unix.shell
mailing list