From owner-freebsd-questions@FreeBSD.ORG Wed Jun 23 02:47:42 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D9DA106566C for ; Wed, 23 Jun 2010 02:47:42 +0000 (UTC) (envelope-from freebsd@optimis.net) Received: from mail.optimis.net (mail.optimis.net [69.104.191.124]) by mx1.freebsd.org (Postfix) with ESMTP id E34878FC18 for ; Wed, 23 Jun 2010 02:47:41 +0000 (UTC) Received: from marvin.optimis.net (marvin.optimis.net [192.168.1.3]) by mail.optimis.net (8.14.3/8.14.3) with ESMTP id o5N2lftG080220 for ; Tue, 22 Jun 2010 19:47:41 -0700 (PDT) (envelope-from freebsd@optimis.net) Received: from marvin.optimis.net (localhost [127.0.0.1]) by marvin.optimis.net (8.14.3/8.14.3) with ESMTP id o5N2lenX089982; Tue, 22 Jun 2010 19:47:40 -0700 (PDT) (envelope-from freebsd@optimis.net) Received: (from george@localhost) by marvin.optimis.net (8.14.3/8.14.3/Submit) id o5N2leQo089981; Tue, 22 Jun 2010 19:47:40 -0700 (PDT) (envelope-from freebsd@optimis.net) Date: Tue, 22 Jun 2010 19:47:40 -0700 From: George Davidovich To: freebsd-questions@freebsd.org Message-ID: <20100623024740.GA89047@marvin.optimis.net> References: <4C217217.5060104@comclark.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C217217.5060104@comclark.com> User-Agent: Mutt/1.5.19 (2009-01-05) Subject: Re: .sh & ip address 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, 23 Jun 2010 02:47:42 -0000 On Wed, Jun 23, 2010 at 10:31:51AM +0800, Aiza wrote: > I looking to take the last group number in a ip address and bump the > number by 1. BY the way is there some name for each group of numbers in > the ip address? Octet. > Something like. > > org_ip="10.0.10.2" > short_ip=need command to strip off the 2 so short_ip contains 10.0.10. > and ip_suffix= ends up holding the 2, then add 1 to the ip_suffix. > ip_suffix=$(( ${ip_suffix + 1 )) > org_ip="${short_ip}${ip_suffix}" > > Thinking there must be some common way of manipulating ip addresses that > I just don't know about. man sh | less -p"Parameter Expansion" org_ip=10.0.10.2 ${org_ip##*.} # yields 2 ${org_ip%.*} # yields 10.0.10 Do read the manpage. -- George