stealth@caen.engin.umich.edu (Mike Peltier) (11/24/89)
#!/bin/sh # This shell script uses the contents of an out-of-date active file # as a reference and resets the proper first and last article numbers. # Be sure to turn of your news before running this, and afterwards # the output will be an up to date, ready to use active file. # This script should be invoked as: # % rebuild_active < oldactive > newactive & # Be advised that it will take a LONG time. SPOOL=/usr/local/news/spool read ACTIVE_LINE while [ -n "$ACTIVE_LINE" ] do NEWSGROUP=`echo $ACTIVE_LINE | cut -f1 -d\ ` MOD=`echo $ACTIVE_LINE | cut -f4 -d\ ` PN=`echo $NEWSGROUP | sed -e "s:\\.:/:g"` eval `ls -1tcr | sed -n '1s/^/FIRST=/p # Here is the improvement $s/^/LAST=/p'` if [ -s /tmp/$$redo-active ] then NUM="00000"$FIRST CHOP="`echo $NUM | sed -e "s/.....$//"`" FIRST="`echo $NUM | sed -e s/$CHOP//`" NUM="00000"$LAST CHOP="`echo $NUM | sed -e "s/.....$//"`" LAST="`echo $NUM | sed -e s/$CHOP//`" else FIRST="`echo $ACTIVE_LINE | cut -f3 -d\ `" LAST=$FIRST fi echo $NEWSGROUP $LAST $FIRST $MOD read ACTIVE_LINE done exit ------------------- At the suggestion of Marcus Watts, I removed the file head/tail business and replaced it with the amazingly elegant "eval" statement that you see above. Goes to show the power of long experience involved in writing good code!