Created
June 25, 2014 08:37
-
-
Save migonzalvar/884a94660c83a46a1bb4 to your computer and use it in GitHub Desktop.
This file contains 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/env python3 | |
""" grep.py - Search a string in a file. """ | |
import sys | |
# Parse arguments | |
pattern, file_name = sys.argv[1:3] | |
with open(file_name, 'rt') as f: | |
for n, line in enumerate(f, 1): | |
if pattern in line: | |
print('Line %03d:' % n, line, end='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment