Subject: Re: [ sed ] - help required : matching range of IP address
To: None <netbsd-users@netbsd.org>
From: Mathew Richardson <mrr@nexthop.com>
List: netbsd-users
Date: 06/28/2002 12:03:42
> Joel CARNAT <joel_carnat@yahoo.fr> [Fri, Jun 28, 2002 at 05:46:51PM +0200]:
>Hi,
>
> I know this is not "strictly" a NetBSD related question but hey... I'm
>using NetBSD :)p
> It's been an hour (or 2) that I'm looking on the web and didn't find
>THE thing...
>
> I have to import ISC/DHCPD leases to export them to another one.
> How can I match a range of IP address with sed ?
>
> Let's say there are 192.155.{10 to 99}.0 and I want to get only
>192.155.{29 and 30}.0
> If I use "sed ... [23][90]..." I may get 29 and 30 but also 20 and 39
>:(
> I've also tried "...[\(29\)\(30\)]..." but it didn't work...
>
> Can anyone give me the holly regexp please ?
<snip>
Just (29)|(30) should work, with extended regular expressions:
mrr@foo $ cat > nums
20
29
30
39
mrr@foo $ cat nums | sed -E 's!(29)|(30)!found!g'
20
found
found
39
Actually, the parens even appear to be unnecessary...
mrr