Created
September 23, 2014 13:42
-
-
Save meeuw/805cec7c161a21202da2 to your computer and use it in GitHub Desktop.
grep but only output what matches
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/python | |
import fileinput | |
import sys | |
import re | |
pattern = sys.argv.pop(1) | |
for line in fileinput.input(): | |
m = re.search(pattern, line) | |
if m: | |
for g in m.groups(): print g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment