Skip to content

Instantly share code, notes, and snippets.

@spellancer
Created October 31, 2013 16:12
Show Gist options
  • Save spellancer/7252422 to your computer and use it in GitHub Desktop.
Save spellancer/7252422 to your computer and use it in GitHub Desktop.
4
import re
fr = open ("access.log", "r")
fw = open ("output.txt","w")
pipv4 = re.compile ("^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])((\.25[0-5]|\.2[0-4][0-9]|\.1[0-9][0-9]|\.[0-9][0-9]|\.[0-9]){3}) ")
c = 0
l = fr.readlines()
for i in l:
if pipv4.search(i)!=None:
c += 1
fw.write(str(c))
fr.close()
fw.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment