From owner-freebsd-questions Fri Sep 4 09:07:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA11811 for freebsd-questions-outgoing; Fri, 4 Sep 1998 09:07:00 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from netra.graphnet.com (netra.graphnet.com [192.206.112.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA11806 for ; Fri, 4 Sep 1998 09:06:59 -0700 (PDT) (envelope-from romank@graphnet.com) Received: from graphnet.com (roman.graphnet.com [192.206.112.93]) by netra.graphnet.com (8.8.8/8.8.6) with ESMTP id MAA29569; Fri, 4 Sep 1998 12:05:51 -0400 (EDT) Message-ID: <35F01196.BA6A7F7F@graphnet.com> Date: Fri, 04 Sep 1998 12:13:10 -0400 From: Roman Katsnelson Organization: Graphnet, Inc X-Mailer: Mozilla 4.05 [en] (WinNT; U) MIME-Version: 1.0 To: Dan Nelson CC: "q's" Subject: Re: grep question References: <35EFEEA4.65B3315F@graphnet.com> <19980904095358.A7658@emsphone.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > --- deleterecord --- > #!/bin/sh > > file="file.txt" > recid=$1 > # get the starting line number for the record we're interested in > line=$(grep -n "^# --->$recid" $file) # grep -n prepends line with line num > linenum=${line%%:*} # remove everything after the first colon > > if [ -z "$linenum" ] ; then > echo Record $recid not found > exit 1 > fi > > # calculate the start and end line numbers > start=$(( $linenum - 2 )) > end=$(( $linenum + 13 )) > > # delete the offending record > sed -e "${start}-${end}d" < $file > $file.tmp Thank you! When I test this on an actual record, though, it returns: sed: 1: "270-285d": invalid command code - any ideas? btw, what's a good book on sed and awk and sh etc.? mucho thanks AA roman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message