Created
September 4, 2015 07:09
-
-
Save tanjo/de1bc2ed90e645cc74be to your computer and use it in GitHub Desktop.
python-search-file-text
This file contains hidden or 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 | |
# -*- coding:utf-8 -*- | |
""" | |
tasks.py | |
invoke 用 ファイル検索プログラム | |
""" | |
__author__ = "tanjo" | |
__version__ = "0.0.1" | |
__date__ = "2014-08-06" | |
from invoke import run, task | |
@task | |
def search(path="", word=""): | |
if len(path) > 0: | |
f = open(path, "r") | |
lines = f.readlines() | |
f.close() | |
for line in lines: | |
if word in line: | |
print line | |
else: | |
print """ | |
[Usage] | |
search --path 'file/path/' --word 'word' | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment