Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # encoding: utf-8
- #
- # Copyright (c) 2010 Doug Hellmann. All rights reserved.
- #
- """Simplistic grep implementation
- """
- #end_pymotw_header
- import fileinput
- import glob
- import sys
- from_base = sys.argv[1]
- to_base = sys.argv[2]
- files = sys.argv[3:]
- for line in fileinput.input(files, inplace=True):
- if fileinput.isfirstline():
- sys.stderr.write('Started processing %s\n' %
- fileinput.filename())
- sys.stderr.write('Directory contains: %s\n' %
- glob.glob('etc_hosts.txt*'))
- line = line.rstrip().replace(from_base, to_base)
- print line
- sys.stderr.write('Finished processing\n')
- sys.stderr.write('Directory contains: %s\n' %
- glob.glob('etc_hosts.txt*'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement