Created
August 31, 2015 13:40
-
-
Save enshiromashiro/1cacf5020e4db67b0897 to your computer and use it in GitHub Desktop.
Counting supplied word in the file.
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
#!/usr/bin/python | |
import sys | |
args = sys.argv | |
if len(args) < 2: | |
print "usage: count.py [file] [word]" | |
quit() | |
count = 0 | |
for line in open(args[1], 'r'): | |
count += line.count(args[2]) | |
print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment