Hi,
I just started to learn awk and thought this would be easy. I hoped I could find examples which would do similar things and modify those examples for my purpose, but I can't get it to work.
I'd like to generate all IP addresses of a Class B subnet, e.g.
10.0.0.0/16
10.0.0.0
10.0.0.1
...
10.0.0.255
10.0.1.0
...
10.0.255.255
I thought I could combine something like this "BEGIN {for ( i=0; i<256; i++)" with a text file (ip.txt) that contains the first 3 bytes. The first part was easy, so the text file would look like:
10.0.0.
10.0.1.
...
10.0.255
But I can't get each line ($0) printed 256 times together with a number incremented by one until it reaches 255.
Can you help me? Is the approach ok or would you use a different way?
Kind Regards,
P.
I just started to learn awk and thought this would be easy. I hoped I could find examples which would do similar things and modify those examples for my purpose, but I can't get it to work.
I'd like to generate all IP addresses of a Class B subnet, e.g.
10.0.0.0/16
10.0.0.0
10.0.0.1
...
10.0.0.255
10.0.1.0
...
10.0.255.255
I thought I could combine something like this "BEGIN {for ( i=0; i<256; i++)" with a text file (ip.txt) that contains the first 3 bytes. The first part was easy, so the text file would look like:
10.0.0.
10.0.1.
...
10.0.255
But I can't get each line ($0) printed 256 times together with a number incremented by one until it reaches 255.
Can you help me? Is the approach ok or would you use a different way?
Kind Regards,
P.