您的位置:首页 > 其它

测试一个目录下的文件共有多少行

2012-03-30 16:09 211 查看
用法: python test.py /home/lx/c/test

#test how much lines in a directory.
import os,sys

def cout( current_doc ):
os.chdir( current_doc )
doc_list = os.listdir( current_doc )

for i in doc_list:
if os.path.isfile( i ):
os.system( 'wc -l ' + i + ' >> l')

os.system( "awk '{total += $1; print total }' l ")
os.system( "rm l" )

if __name__ == "__main__":
cout( sys.argv[1] )


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐