From owner-freebsd-questions@FreeBSD.ORG Wed Feb 11 11:12:22 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D10C10656D0 for ; Wed, 11 Feb 2009 11:12:22 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [220.233.188.227]) by mx1.freebsd.org (Postfix) with ESMTP id D2F4F8FC13 for ; Wed, 11 Feb 2009 11:12:21 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id n1BAlIgx086012 for ; Wed, 11 Feb 2009 21:47:18 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Wed, 11 Feb 2009 21:47:17 +1100 (EST) From: Ian Smith To: questions@freebsd.org Message-ID: <20090211213011.C38905@sola.nimnet.asn.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Subject: sh parameter substitution problem 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, 11 Feb 2009 11:12:23 -0000 I'm getting nowhere trying to parse out IP addresses from strings of this form in /bin/sh, which have been awk'd out of 'tail named.run': addr='195.68.176.4#1440:' addr='195.68.176.4#16811:' addr='195.68.176.4#276:' sh(1) in hand, I've tried: ip=${addr:%#*} ip=${addr:%%#*} ip=${addr:%[#]*} ip=${addr:%%[#]*} but all of these report './testbit: 7: Syntax error: Bad substitution' How can I split these strings to exclude the '#' and all beyond, preferably using sh syntax, at least without resorting to perl? Please cc me as I'm only subscribed to the digest. TIA, Ian