Skip to content

Instantly share code, notes, and snippets.

@tanjo
Created September 4, 2015 07:09
Show Gist options
  • Save tanjo/de1bc2ed90e645cc74be to your computer and use it in GitHub Desktop.
Save tanjo/de1bc2ed90e645cc74be to your computer and use it in GitHub Desktop.
python-search-file-text
#!/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