From owner-freebsd-questions@FreeBSD.ORG Sun Jul 3 20:47:31 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 77ED616A41C for ; Sun, 3 Jul 2005 20:47:31 +0000 (GMT) (envelope-from fbsd_user@a1poweruser.com) Received: from mta13.adelphia.net (mta13.adelphia.net [68.168.78.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC76643D48 for ; Sun, 3 Jul 2005 20:47:30 +0000 (GMT) (envelope-from fbsd_user@a1poweruser.com) Received: from barbish ([69.172.31.81]) by mta13.adelphia.net (InterMail vM.6.01.04.01 201-2131-118-101-20041129) with SMTP id <20050703204730.TMRZ14360.mta13.adelphia.net@barbish> for ; Sun, 3 Jul 2005 16:47:30 -0400 From: "fbsd_user" To: "freebsd-questions@FreeBSD. ORG" Date: Sun, 3 Jul 2005 16:47:24 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <20050703163319.58bd970c@phobos.mars.bsd> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Cc: Subject: RE: help with she script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: fbsd_user@a1poweruser.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2005 20:47:31 -0000 Thanks guys your solutions have worked and I am learning allot along the way. This is my last coding problem. target="check-state" # Find the rule number of the target rule where you want the doorman # pass rules inserted before. ruleno=`ipfw list | sed -n -e "s/00\([0-9]*\) $target/\1/p"` The output of 'ipfw list' looks like this nnnnn a 5 position sequence rule number blank followed by a empty single position x-x a 10 to 80 position rule text When the rule text matches the target text I want the first 5 position rule number to go into ruleno. Large rules files may use all 5 positions and then the above code will fail to get the rule number. Tried to remove the s/00\ but had syntax problems.