1) 快速的将当前脚本的输入,输出重定向:
fo=file('%s.out'%(func.__name__),'w+')
fe=file('%s.err'%(func.__name__),'w+')
fi=file('/dev/null','r')
os.dup2(fo.fileno(), sys.stdout.fileno())
os.dup2(fe.fileno(), sys.stderr.fileno())
os.dup2(fi.fileno(), sys.stdin.fileno())
2) setup.py install某个模块的时候,建议重新修正一下目录:
setup.py
module_folder
|_ moudle.py
|_ __init__.py
必须有__init__.py,形式如下:
__all__ = ['mcpack']
3)python setup install
from mcpack import *
python install脚本:
python setup.py install --record files.txt
cat files.txt | xargs rm -rf
4) 先转换编码,再进行grep
code_grep.sh
pattern=$1
for x in `find . -type f -name "*.php"` ;
do
iconv -f utf8 -t gbk -o /tmp/temp.iconv $x ;grep "$pattern" /tmp/temp.iconv 1>/dev/null 2>&1ret=$?;if [ "$ret" == "0" ];thenecho $x;grep "$pattern" /tmp/temp.iconvecho ""fi;
done;
No comments:
Post a Comment