Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Aug 2005 19:30:20 -0500
From:      "antenneX" <antennex@swbell.net>
To:        "Giorgos Keramidas" <keramida@ceid.upatras.gr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Script help using "cut"
Message-ID:  <001201c5a90c$2d9701e0$0200000a@SAGEAME>
References:  <20050824130412.GB877@orion.daedalusnetworks.priv><000801c5a8ca$aca01680$0200000a@SAGEAME> <20050824165251.GA855@orion.daedalusnetworks.priv>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message ----- 
From: "Giorgos Keramidas" <keramida@ceid.upatras.gr>
To: "antenneX" <antennex@swbell.net>
Cc: <freebsd-questions@freebsd.org>
Sent: Wednesday, August 24, 2005 11:52 AM
Subject: Re: Script help using "cut"


> On 2005-08-24 11:41, antenneX <antennex@swbell.net> wrote:
> >Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> >> sed -e 's/)[[:space:]]*$//' -e 's/^.*@//'
> >>
> >> or you can use as complex regular expressions as necessary to cut
> >> specific parts of the line:
> >>
> >> sed -e 's/^.*@\([^)]*\))[[:space:]]*$/\1/'
> >
> > In fact, my very next script line uses sed(1) to add the TAB and
the
> > RHS to the sendmail access file:
> > sed 's/$/       REJECT/g' tmpfile >> /etc/mail/access
> >
> > I'll bet my line could be incorporated with yours.
>
> Sure.  It's probably also a good idea to use mv(1) with a temporary
file
> residing under /etc/mail too, to make sure the update to the access
map
> is as close to being an ``atomic operation'' as possible:
>
> % accesstmp=`mktemp /etc/mail/access.tmp.XXXXXX`
> % if [ -z "${accesstmp}" ]; then
> % exit 1
> % fi
> %
> % ( cat /etc/mail/access ;
> %   awk '{whatever else here}' tmpfile | \
> %   sed -e 's/^.*@\([^)]*\))[[:space:]]*$/\1 REJECT/' ) >
"${accesstmp}"
> % if [ $? -ne 0 ]; then
> % exit 1
> % fi
> % mv "${accesstmp}" /etc/mail/access
> % cd /etc/mail && make access.db
>

Giorgos, that's pretty snazzy compared to my crude script. Will now
work on weaving it all together. Eliminates a bit more manual effort.

I like it & appreciate the extra help!

Best regards,
Jack L. Stone




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001201c5a90c$2d9701e0$0200000a>