On Sun, Mar 21, 2004 at 12:07:29AM -0800, Bob Miller wrote:
> Jacob Meuser wrote:
> 
> > #!/bin/sh
> > 
> > TEMPDIR=`mktemp -d`
> > 
> > while read addr junk
> > do
> >     dom=`echo $addr | cut -d '@' -f 2`
> >     echo $addr OK >> $TEMPDIR/$dom
> > done
> > 
> > MYDIR=`pwd`
> > cd $TEMPDIR
> > 
> > for i in *
> > do
> >     sort $i
> >     echo $i REJECT
> > done
> > 
> > cd $MYDIR
> > rm -rf $TEMPDIR
> > 
> > exit 0
> 
> Very good! (-:

Thanks :)

> May I suggest one small improvement?  Set up a trap handler to delete
> the temp dir.  That way it'll be cleaned up even if the script is
> interrupted (e.g., you pipe the output through less and quit before
> reaching the end).
> 
>     #!/bin/sh
>     TEMPDIR="`mktemp -d`"
>     trap 'rm -rf "$TEMPDIR"' EXIT
>     # ... rest of script ...

Thanks for the pointer.  I was actually just looking at such trap
handlers in the XFree86 build scripts.

Also, this part:

> > MYDIR=`pwd`
> > cd $TEMPDIR
> > 
> > for i in *
> > do
> >     sort $i
> >     echo $i REJECT
> > done
> > 
> > cd $MYDIR
> > rm -rf $TEMPDIR

could be replaced with:

for i in $TEMPDIR/*
do
        sort $i
        echo `basename $i` REJECT
done

-- 
<[EMAIL PROTECTED]>
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to