From owner-freebsd-questions@FreeBSD.ORG Thu Aug 25 00:30:23 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4053716A41F for ; Thu, 25 Aug 2005 00:30:23 +0000 (GMT) (envelope-from antennex@swbell.net) Received: from ylpvm12.prodigy.net (ylpvm12-ext.prodigy.net [207.115.57.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7DCE43D45 for ; Thu, 25 Aug 2005 00:30:22 +0000 (GMT) (envelope-from antennex@swbell.net) Received: from pimout5-ext.prodigy.net (pimout5-int.prodigy.net [207.115.4.21]) by ylpvm12.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id j7P0UJQM005723 for ; Wed, 24 Aug 2005 20:30:20 -0400 X-ORBL: [65.68.247.73] DomainKey-Signature: a=rsa-sha1; s=sbc01; d=swbell.net; c=nofws; q=dns; h=message-id:reply-to:from:to:cc:references:subject:date: mime-version:content-type:content-transfer-encoding:x-priority: x-msmail-priority:x-mailer:x-mimeole; b=H7+0OVSY2CVYb3ySjs1RIoWUN6jPEQNlWMvMSsqaDQvaHernwpLA0Md5xkkrHs/Q2 j4yg6TkA58647sIoGW/Lw== Received: from SAGEAME (adsl-65-68-247-73.dsl.crchtx.swbell.net [65.68.247.73]) by pimout5-ext.prodigy.net (8.13.4 outbound domainkey aix/8.13.4) with SMTP id j7P0UKdd521376; Wed, 24 Aug 2005 20:30:20 -0400 Message-ID: <001201c5a90c$2d9701e0$0200000a@SAGEAME> From: "antenneX" To: "Giorgos Keramidas" References: <20050824130412.GB877@orion.daedalusnetworks.priv><000801c5a8ca$aca01680$0200000a@SAGEAME> <20050824165251.GA855@orion.daedalusnetworks.priv> Date: Wed, 24 Aug 2005 19:30:20 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 Cc: freebsd-questions@freebsd.org Subject: Re: Script help using "cut" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: antenneX List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2005 00:30:23 -0000 ----- Original Message ----- From: "Giorgos Keramidas" To: "antenneX" Cc: Sent: Wednesday, August 24, 2005 11:52 AM Subject: Re: Script help using "cut" > On 2005-08-24 11:41, antenneX wrote: > >Giorgos Keramidas 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