Find cmd
Find cmd with python programing python at page320
Unix find cmd:
find . -name "*.py " -print -exec fgrep popen{}\;
from glob import glob
import os def findWithExt(type):
for file in glob(type):
if 'xlian7164584' in open(file).read():
print(file)
print('current directory is %s' % os.path.abspath('.')) ext='*.*'
findWithExt(ext)

find cmd:
"""
return all files matching a filename patten at and below a root directory; custom version of the now dreprecated find modelue in the standard lib:
imprt as "Tools.find" like original ,but uses os.walk loop,has no support for pruning subdires,and
is runnable as top-level script; find() is a generator that uses the os.walk() generator to yield just
mathing filenames:use findlist() to forse result list generation;
"""
import fnmatch
from glob import glob
import os def find(pattern,startdir=os.curdir):
for (thisDir,subHere,filesHere) in os.walk(startdir):
for name in subHere +filesHere:
if fnmatch.fnmatch(name,pattern):
fullpath = os.path.join(thisDir,name)
yield fullpath def findlist(pattern,startdir=os.curdir,dosort=False):
matches = list(find(pattern,startdir))
if dosort:
mathches.sort()
return matches def findWithExt(type):
for file in glob(type):
if 'xlian7164584' in open(file).read():
print(file)
print('current directory is %s' % os.path.abspath('.')) #ext='*.*'
#findWithExt(ext) if __name__ =='__main__':
import sys
namepattern,startdir = sys.argv[1],sys.argv[2]
for name in find(namepattern,startdir):
print(name)

Find cmd的更多相关文章
- 让 windows 下的命令行程序 cmd.exe 用起来更顺手
在 Windows 下使用 Larave 框架做开发,从 Composer 到 artisan 总是避免不了和 cmd.exe 打交道,系统默认的命令行界面却是不怎么好看,且每行显示的字符数是做了限制 ...
- cmd窗口编码设置
问题描述:不知道误操作了什么,导致cmd窗口的鼠标显示位置出现错位,如下: 现在要将鼠标位置调整回来. 使用工具:cmd. 操作步骤: 1.查看cmd属性可以看到 可以看到是UTF-8编码格式的,我们 ...
- Windows cmd 长时间不输出新内容 直到按下ctrl + c 取消或者回车的解决办法
换了一台新电脑, 在使用 ant 拷贝大量文件的时候 cmd 窗口过了很久没有继续输出新的内容,远远超过平时的耗时, 以为已经卡死 按下 ctrl + c 取消, 这时并没有取消, 而是输出了新内容, ...
- 创建maven项目(cmd 命令)
2016五月 22 原 创建maven项目(cmd 命令) 分类:maven (994) (0) 1.普通方式创建 1)进入cmd窗口执行 mvn archetype:generate 2) 光标停止 ...
- js模块定义——支持CMD&AMD&直接加载
/* animate */ //直接加载 (function() { var animate = {} //balabala window.animate = animate; })(); //AMD ...
- 不显示cmd窗口运行jar包
今天,打开导出的jar包,发现并不能运行,查看jar包中的META-INF文件夹下的MANIFEST.MF文件,发现MANIFEST.MF中并没有Main-Class,于是,就手动添加相应的信息,本项 ...
- 执行插入语句,object val = cmd.ExecuteScalar() val = null
在写接口的过程中遇到错误:空对象不能转换为值类型 因为我们使用的是petapoco,经过调试后发现是 object val = cmd.ExecuteScalar() 这一句造成的报错, val = ...
- Linux Cmd Tool 系列之—alias
The alias cmd list your current aliases. For example : alias Use alias to shorten a long cmd in curr ...
- 使用cmd打开java文件,报错:“错误,编码GBK的不可映射字符”
今天使用EditPlus写了一个小程序,用cmd运行时报错--"错误,编码GBK的不可映射字符". 处理办法是用EditPlus另存为时,把编码格式由UTF-8改为ANSI. 然后 ...
- cmd命令汇总
一 cmd 命令 cmd命令大全(第一部分) winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构(WMI) wupdmgr------ ...
随机推荐
- input type=file 图片上传相关
HTML: <input type="file" name="address" onchange='PreviewImage(this)' value ...
- a 标签 启用或禁用点击事件
<a href="#" id="btnAuthCode" class="authCode_btn">获取验证码</a> ...
- Multiple annotations found at this line
Multiple annotations found at this line 在使用MyEclipse的时候,通过MVN导入项目时候,webapp下面的JSP页面报了如下的错误: 这种情况通常的原因 ...
- HttpPostedFile类的使用方法
HttpPostedFile注意事项: (1) HttpPostedFile提供对客户端已上载的单独文件的访问. (2) 对于客户端已上载的文件,最好先保存到服务器,再访问:而不是直接访问 ...
- 了解学习JS中this的指向
[转] 首先必须要说的是,this的指向在函数定义的时候是确定不了的,只有函数执行的时候才能确定this到底指向谁,实际上this的最终指向的是那个调用它的对象(这句话有些问题,后面会解释为什么会有问 ...
- 将List下载到本地保存为Excel
直接附上代码 /// <summary> /// 将List保存为Excel /// </summary> /// <typeparam name="T&quo ...
- springboot+redis
上篇整合了DB层,现在开始整合缓存层,使用redis. springboot驱动注解,使用spring注入JedisPool便可封装自己的redis工具类. package hello.configu ...
- wifi万能钥匙自媒体平台开放注册(付注册流程)
12月13日,有网友爆料,wifi万能钥匙自媒体开放注册,看来自媒体还没有达到饱和阶段,也印证了自媒体时代才刚刚到来.现在这个自媒体的时代,几乎大多互联网企业都开通了自己的自媒体,比较知名的像今日头条 ...
- 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定
阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...
- ruby 随笔
1.A Server is running获取PID lsof -wni tcp:3000关闭PID kill -9 pID2.rubymine注册码http://idea.lanyus.com/ 3 ...