Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active December 19, 2017 00:24
Show Gist options
  • Save BlogBlocks/683479a10baff886b1fa32729c3c612f to your computer and use it in GitHub Desktop.
Save BlogBlocks/683479a10baff886b1fa32729c3c612f to your computer and use it in GitHub Desktop.
Simple use:
#2 argvs filename and search term/word
#USAGE below to search the file ElementTree.py for the word 'parse ':
#python SearchFile.py ElementTree.py parse
import sys
filename = sys.argv[1]
search = sys.argv[2]
#f = open("ElementTree.py")
f = open(filename)
lines = f.readlines()
count = 0
for line in lines:
count = count +1
line = line.replace("\n", "")
#if "XML" in line:
if search in line:
print count,":",line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment