From owner-freebsd-questions@FreeBSD.ORG Wed Jun 29 03:17:08 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 7462616A41C for ; Wed, 29 Jun 2005 03:17:08 +0000 (GMT) (envelope-from Mike.Jeays@rogers.com) Received: from smtp101.rog.mail.re2.yahoo.com (smtp101.rog.mail.re2.yahoo.com [206.190.36.79]) by mx1.FreeBSD.org (Postfix) with SMTP id 1817543D48 for ; Wed, 29 Jun 2005 03:17:07 +0000 (GMT) (envelope-from Mike.Jeays@rogers.com) Received: (qmail 71453 invoked from network); 29 Jun 2005 03:17:07 -0000 Received: from unknown (HELO ?192.168.2.150?) (mjeays2551@24.114.152.139 with plain) by smtp101.rog.mail.re2.yahoo.com with SMTP; 29 Jun 2005 03:17:06 -0000 From: Mike Jeays To: fbsd_user@a1poweruser.com In-Reply-To: References: Content-Type: text/plain Message-Id: <1120015025.659.12.camel@chaucer> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 28 Jun 2005 23:17:05 -0400 Content-Transfer-Encoding: 7bit Cc: "freebsd-questions@FreeBSD. ORG" Subject: Re: Shell script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2005 03:17:08 -0000 On Tue, 2005-06-28 at 22:52, fbsd_user wrote: > My sh shell script ability is not that good. > Have 2 simple coding problems. > > How do I code a statement to subtract one from a field. > > $rulenum = $rulenum - 1 > $rulenum = '$rulenum - 1' > > one='1' > $rulenum = $rulenum - $one > $rulenum='$rulenum - $one' > > None of that works. must really be simple. > > I also have this line > inruleno=`ipfw list | sed -n -e "s/00\([0-9]*\) $inblock/\1/p"` > > This works ok, the search argument is s/00\ but that is not good enough > because the number can be 0 to 65535. The sed -n -e "s/00\([0-9]*\ needs to > be changed to just return the first word. > > > Thanks for any help you can give. > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" "man expr" to give the short answer to your first question: As an example, x=`expr $x + 1` 536 ~ $ x=4 537 ~ $ x=`expr $x + 1` 538 ~ $ echo $ Note the back-quotes to execute a command and return the result, and the need for spaces between each token in the expr command.