Skip to content

Instantly share code, notes, and snippets.

@enshiromashiro
Created August 31, 2015 13:40
Show Gist options
  • Save enshiromashiro/1cacf5020e4db67b0897 to your computer and use it in GitHub Desktop.
Save enshiromashiro/1cacf5020e4db67b0897 to your computer and use it in GitHub Desktop.
Counting supplied word in the file.
#!/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