Created
July 9, 2020 16:30
-
-
Save fyoorer/6cefd3284995192305d154b6382a46da to your computer and use it in GitHub Desktop.
Count number of ips in a file with cidr range per line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dict={} | |
for i in range(1,33): | |
dict[i]=2**(32-i) | |
with open('amz.txt') as f: | |
for line in f: | |
sn = line.split('/')[1] | |
cur = dict[int(sn.strip())] | |
ipcount = ipcount + cur | |
print(ipcount) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment