Skip to content

Instantly share code, notes, and snippets.

@fyoorer
Created July 9, 2020 16:30
Show Gist options
  • Save fyoorer/6cefd3284995192305d154b6382a46da to your computer and use it in GitHub Desktop.
Save fyoorer/6cefd3284995192305d154b6382a46da to your computer and use it in GitHub Desktop.
Count number of ips in a file with cidr range per line
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