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------ ...
随机推荐
- 一些Asp.Net面试题答案
工作时间长了总是用同样的一些东西 其他的有些生疏 闲来看看面试题练习一下: 题目出处嘛...aspnet-tests-for-juniors 转载请注明来源:http://www.cnblogs ...
- 【JAVA】 UIMnager
Java'中的几种Look and Feel 1.Metal风格 (默认) String lookAndFeel = "javax.swing.plaf.metal.MetalLookAnd ...
- MongoDB-C#驱动基本操作
#region IMongoQuery //Query.EQ("", val);//字段值=val //Query.NE("", val);//字段值!=val ...
- 李洪强经典面试题145-Runloop
李洪强经典面试题145-Runloop Runloop 什么是 Runloop? 从字面上讲就是运行循环. 它内部就是do-while循环,在这个循环内部不断地处理各种任务. 一个线程对应一个Ru ...
- AJAX实现跨域的三种方法
由于在工作中需要使用AJAX请求其他域名下的请求,但是会出现拒绝访问的情况,这是因为基于安全的考虑,AJAX只能访问本地的资源,而不能跨域访问. 比如说你的网站域名是aaa.com,想要通过AJAX请 ...
- JQuery中on()函数详解
JQuery API中定义的on方法,专业名词很多,读起来并不是那么容易,而对于开发人员知道函数怎么使用就可以了.本文将JQuery的说明翻译如下: on(events,[selector],[dat ...
- JavaScript slice() 方法
JavaScript slice() 方法 JavaScript Array 对象 实例 在数组中读取元素: var fruits = ["Banana", "Oran ...
- Software Solutions CACHE COHERENCE AND THE MESI PROTOCOL
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION Software cache cohere ...
- Qt动画效果展示(文艺IT男)
该程序使用应用程序单窗口,主窗口继承于QMainWindow:主窗口有5个QToolButton部件(窗口底部的四个以及窗口中央的一个),单击窗口底部的QToolButton部件可以使窗口中央的那个Q ...
- C# 获取计算机信息
//C#获取当前计算机的系统信息 //系统标识符和版本号 string strSystem = Environment.OSVersion.ToString(); //获取映射到进程上下文的物理内存量 ...