Date: Tue, 28 Jun 2005 23:17:05 -0400 From: Mike Jeays <Mike.Jeays@rogers.com> To: fbsd_user@a1poweruser.com Cc: "freebsd-questions@FreeBSD. ORG" <freebsd-questions@freebsd.org> Subject: Re: Shell script help Message-ID: <1120015025.659.12.camel@chaucer> In-Reply-To: <MIEPLLIBMLEEABPDBIEGCEOCHHAA.fbsd_user@a1poweruser.com> References: <MIEPLLIBMLEEABPDBIEGCEOCHHAA.fbsd_user@a1poweruser.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1120015025.659.12.camel>