Date: Tue, 22 Jun 2010 19:47:40 -0700 From: George Davidovich <freebsd@optimis.net> To: freebsd-questions@freebsd.org Subject: Re: .sh & ip address Message-ID: <20100623024740.GA89047@marvin.optimis.net> In-Reply-To: <4C217217.5060104@comclark.com> References: <4C217217.5060104@comclark.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100623024740.GA89047>