Expand IP address range 
Author Message
 Expand IP address range

I have an input file listed below which contains IP addresses with
other information tacked on after each address. Some of the IP address
are set up in ranges with a '-' and some of them have the wildcard
('*') within them. I need to do is read the file and create a new file
that has non-expanded ip addresses expanded within the range specified
from the existing file. Some of the addresses below also have multiple
'-'s. All the '-'s would have to be expanded. I don't care about
expanding the ip address with the wildcards (*), just the ones with
the '-'s in them.

Input File
===========
10.40.6.130:m0ther:*:8:3:120::m00se:
10.40.6.131:m0ther:*:8:3:120::m00se:
10.40.6.140:m0ther:*:8:3:120::m00se:
10.42.1-3.240-243:m0ther:*:8:2:120::m00se:
10.60.1.2-3:m0ther:*:8:3:120::m00se:
10.60.2.*:m0ther:*:8:2:300::m00se:
10.90.*.*:m0ther:*:8:2:240::m00se:
10.100.*.231-235:m0ther:*:8:2:120::m00se:
152.10-12.*.*:m0ther:*:8:3:120::m00se:

The new output file should look like the following:

Output File
===========
10.40.6.130:m0ther:*:8:3:120::m00se:
10.40.6.131:m0ther:*:8:3:120::m00se:
10.40.6.140:m0ther:*:8:3:120::m00se:

10.42.1.240:m0ther:*:8:2:120::m00se:
10.42.1.241:m0ther:*:8:2:120::m00se:
10.42.1.242:m0ther:*:8:2:120::m00se:
10.42.1.243:m0ther:*:8:2:120::m00se:
10.42.2.240:m0ther:*:8:2:120::m00se:
10.42.2.241:m0ther:*:8:2:120::m00se:
10.42.2.242:m0ther:*:8:2:120::m00se:
10.42.2.243:m0ther:*:8:2:120::m00se:
10.42.3.240:m0ther:*:8:2:120::m00se:
10.42.3.241:m0ther:*:8:2:120::m00se:
10.42.3.242:m0ther:*:8:2:120::m00se:
10.42.3.243:m0ther:*:8:2:120::m00se:

10.60.1.2:m0ther:*:8:3:120::m00se:
10.60.1.3:m0ther:*:8:3:120::m00se:

10.60.2.*:m0ther:*:8:2:300::m00se:
10.90.*.*:m0ther:*:8:2:240::m00se:

10.100.*.231:m0ther:*:8:2:120::m00se:
10.100.*.232:m0ther:*:8:2:120::m00se:
10.100.*.233:m0ther:*:8:2:120::m00se:
10.100.*.234:m0ther:*:8:2:120::m00se:
10.100.*.235:m0ther:*:8:2:120::m00se:

152.10.*.*:m0ther:*:8:3:120::m00se:
152.11.*.*:m0ther:*:8:3:120::m00se:
152.12.*.*:m0ther:*:8:3:120::m00se:

I separated the output file here in this email with a blank line to
make it easier to view the expanded records, the blank line shouldn't
be in the final output file. I think this can be done in AWK, I'm just
not sure how to accomplish it.

Thanks
Rich K.



Wed, 16 Nov 2005 03:01:04 GMT  
 Expand IP address range

Quote:

>I have an input file listed below which contains IP addresses with
>other information tacked on after each address. Some of the IP address
>are set up in ranges with a '-' and some of them have the wildcard
>('*') within them. I need to do is read the file and create a new file
>that has non-expanded ip addresses expanded within the range specified
>from the existing file. Some of the addresses below also have multiple
>'-'s. All the '-'s would have to be expanded. I don't care about
>expanding the ip address with the wildcards (*), just the ones with
>the '-'s in them.

>Input File
>===========
>10.40.6.130:m0ther:*:8:3:120::m00se:
>10.40.6.131:m0ther:*:8:3:120::m00se:
>10.40.6.140:m0ther:*:8:3:120::m00se:
>10.42.1-3.240-243:m0ther:*:8:2:120::m00se:
>10.60.1.2-3:m0ther:*:8:3:120::m00se:
>10.60.2.*:m0ther:*:8:2:300::m00se:
>10.90.*.*:m0ther:*:8:2:240::m00se:
>10.100.*.231-235:m0ther:*:8:2:120::m00se:
>152.10-12.*.*:m0ther:*:8:3:120::m00se:

>The new output file should look like the following:

>Output File
>===========
>10.40.6.130:m0ther:*:8:3:120::m00se:
>10.40.6.131:m0ther:*:8:3:120::m00se:
>10.40.6.140:m0ther:*:8:3:120::m00se:

>10.42.1.240:m0ther:*:8:2:120::m00se:
>10.42.1.241:m0ther:*:8:2:120::m00se:
>10.42.1.242:m0ther:*:8:2:120::m00se:
>10.42.1.243:m0ther:*:8:2:120::m00se:
>10.42.2.240:m0ther:*:8:2:120::m00se:
>10.42.2.241:m0ther:*:8:2:120::m00se:
>10.42.2.242:m0ther:*:8:2:120::m00se:
>10.42.2.243:m0ther:*:8:2:120::m00se:
>10.42.3.240:m0ther:*:8:2:120::m00se:
>10.42.3.241:m0ther:*:8:2:120::m00se:
>10.42.3.242:m0ther:*:8:2:120::m00se:
>10.42.3.243:m0ther:*:8:2:120::m00se:

>10.60.1.2:m0ther:*:8:3:120::m00se:
>10.60.1.3:m0ther:*:8:3:120::m00se:

>10.60.2.*:m0ther:*:8:2:300::m00se:
>10.90.*.*:m0ther:*:8:2:240::m00se:

>10.100.*.231:m0ther:*:8:2:120::m00se:
>10.100.*.232:m0ther:*:8:2:120::m00se:
>10.100.*.233:m0ther:*:8:2:120::m00se:
>10.100.*.234:m0ther:*:8:2:120::m00se:
>10.100.*.235:m0ther:*:8:2:120::m00se:

>152.10.*.*:m0ther:*:8:3:120::m00se:
>152.11.*.*:m0ther:*:8:3:120::m00se:
>152.12.*.*:m0ther:*:8:3:120::m00se:

>I separated the output file here in this email with a blank line to
>make it easier to view the expanded records, the blank line shouldn't
>be in the final output file. I think this can be done in AWK, I'm just
>not sure how to accomplish it.

use : as FS and split $1 on .

Then expand the array (parsing for * and using split to another
array on -) and set loop conditions for printing the lines necessary.

I'll leave writing the actual code to you.

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,

  Die Anyway         |    v    | That no one could find fault with it.



Wed, 16 Nov 2005 06:14:23 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Anyway to get the server ip address not the browser ip address

2. Locating the memory address range of a network card MAC address

3. Addressing range represented in binary.

4. ISA I/O Address Range

5. Convert an address range into an array

6. accessing I/O address range

7. IP address

8. ip address from ifconfig

9. Extract IP addresses from text file

10. Matching Octet of IP address

11. IP Addresses and Port Numbers

12. Getting the IP Address within RB

 

 
Powered by phpBB® Forum Software