Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- import os
- try:
- dirname = sys.argv[1]
- search_string = sys.argv[2]
- except IndexError:
- exit('error: please provide a directory name and a search string')
- try:
- files = os.listdir(dirname)
- except IOError:
- exit('error: directory does not exist or is not readable')
- line_count = 0
- for filename in files:
- full_path = os.path.join(dirname, search_string)
- for file in files:
- file = open(file).readlines()
- if search_string in file:
- print search_string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement