[PLUG] Complex Search-and-Replace

Vram lamsokvr at xprt.net
Fri Nov 11 00:32:20 UTC 2005


On Thu, 2005-11-10 at 15:43 -0800, Vram wrote:
> On Thu, 2005-11-10 at 11:05 -0800, John Purser wrote:
> > On 11/10/05, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> > >    I have a file of IP addresses, in dotted quad notation. Addresses can have
> > > 2, 3, or 4 of the quads, and I want to convert each address to CIDR. For
> > > example, if I have 123.456 I'd like to convert that to 123.256.0.0/16; if
> > > it's 123.456.789, then I'd like to convert that to 123.456.789.0/24.
> > >
> > >    I know there are multiple tools to do this; I suspect that sed would be the
> > > simplest. Am I better off searching for each group separately (e.g., all /16
> > > separate from all /24 and all /32)? Suggestions appreciated.
> > >
> > > Rich
> > >
> > > --
> > > Richard B. Shepard, Ph.D.               |   Author of "Quantifying Environmental
> > > Applied Ecosystem Services, Inc. (TM)   |  Impact Assessments Using Fuzzy Logic"
> > > <http://www.appl-ecosys.com>     Voice: 503-667-4517         Fax: 503-667-8863
> > > _______________________________________________
> > > PLUG mailing list
> > > PLUG at lists.pdxlinux.org
> > > http://lists.pdxlinux.org/mailman/listinfo/plug
> > >
> > Rich,
> > 
> > Just a couple of quick thoughts:
> > Remember that the CIDR notation isn't nailed to the dotted quad format
> > so just getting the quads won't do it.  It's either going to take a
> > heck of an if statement or you might want to convert the dotted quad
> > to a 32 bit number, then convert that to binary, then convert THAT to
> > a string.  Then count zeros from the right.  For that kind of
> > crunching I'd rather use python or even (if forced) perl.  Certainly a
> > shell script could do it.  I'd just rather have the flexibility of a
> > full scripting language.
> > 
> > I don't know how you got the data but remember that addess 123.456.789
> > might be from domain 123.456.  Therefore the CIDR would be 123.456/16,
> > not 123.456.789/24.
> 
> 
> 
> 
> Someone correct if I am wrong
> 
> But, classful    Class A is   0 to 127  With 0 and 127 abstaining.
> 
> Therefore with classful  notation you could say 123.456.789.0/8

123.123.123.0/8
> 
> But, given 123.456.789.0
123.123.123.0   No clue

I love it when I say something truly STUPID..... hehe


1111 1111  or  F F   can only be 255 no larger...

Octet!!!! hehe

Go ahead

Wack me with the stupid stick!!!!


Lots of help I am!!!


But, I still need the mask;

The mask says it all!!!!!!

<Look what it did for the Lone Ranger>

Vram



> 
> I have NO idea what is happening till you give me THE MASK..
> 
> 
> 
> My story and I am sticking with it...
> 
> 
> Vram
> 
> 
> 
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
> 




More information about the PLUG mailing list