commit
0d921f29b5
1 changed files with 43 additions and 0 deletions
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python |
||||
|
||||
import sys |
||||
import re |
||||
|
||||
buffering=False |
||||
matched=False |
||||
output='' |
||||
start=sys.argv[1] |
||||
match=sys.argv[2] |
||||
end=sys.argv[3] |
||||
|
||||
if len(sys.argv) == 4: |
||||
handle=sys.stdin |
||||
elif len(sys.argv) == 5: |
||||
handle=open(sys.argv[4]) |
||||
|
||||
def debug(line): |
||||
# print line |
||||
pass |
||||
|
||||
for line in handle: |
||||
if re.search(start,line): |
||||
buffering=True |
||||
debug('Started buffering on '+start) |
||||
|
||||
if buffering: |
||||
output+=line |
||||
|
||||
if re.search(match,line): |
||||
matched=True |
||||
debug('Matched on '+match) |
||||
|
||||
if re.search(end,line): |
||||
debug('Finished buffering on '+end) |
||||
if matched: |
||||
print output |
||||
buffering=False |
||||
matched=False |
||||
else: |
||||
output='' |
||||
buffering=False |
||||
|
||||
Loading…
Reference in new issue