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的更多相关文章

  1. 让 windows 下的命令行程序 cmd.exe 用起来更顺手

    在 Windows 下使用 Larave 框架做开发,从 Composer 到 artisan 总是避免不了和 cmd.exe 打交道,系统默认的命令行界面却是不怎么好看,且每行显示的字符数是做了限制 ...

  2. cmd窗口编码设置

    问题描述:不知道误操作了什么,导致cmd窗口的鼠标显示位置出现错位,如下: 现在要将鼠标位置调整回来. 使用工具:cmd. 操作步骤: 1.查看cmd属性可以看到 可以看到是UTF-8编码格式的,我们 ...

  3. Windows cmd 长时间不输出新内容 直到按下ctrl + c 取消或者回车的解决办法

    换了一台新电脑, 在使用 ant 拷贝大量文件的时候 cmd 窗口过了很久没有继续输出新的内容,远远超过平时的耗时, 以为已经卡死 按下 ctrl + c 取消, 这时并没有取消, 而是输出了新内容, ...

  4. 创建maven项目(cmd 命令)

    2016五月 22 原 创建maven项目(cmd 命令) 分类:maven (994) (0) 1.普通方式创建 1)进入cmd窗口执行 mvn archetype:generate 2) 光标停止 ...

  5. js模块定义——支持CMD&AMD&直接加载

    /* animate */ //直接加载 (function() { var animate = {} //balabala window.animate = animate; })(); //AMD ...

  6. 不显示cmd窗口运行jar包

    今天,打开导出的jar包,发现并不能运行,查看jar包中的META-INF文件夹下的MANIFEST.MF文件,发现MANIFEST.MF中并没有Main-Class,于是,就手动添加相应的信息,本项 ...

  7. 执行插入语句,object val = cmd.ExecuteScalar() val = null

    在写接口的过程中遇到错误:空对象不能转换为值类型 因为我们使用的是petapoco,经过调试后发现是 object val = cmd.ExecuteScalar() 这一句造成的报错, val = ...

  8. Linux Cmd Tool 系列之—alias

    The alias cmd list your current aliases. For example : alias Use alias to shorten a long cmd in curr ...

  9. 使用cmd打开java文件,报错:“错误,编码GBK的不可映射字符”

    今天使用EditPlus写了一个小程序,用cmd运行时报错--"错误,编码GBK的不可映射字符". 处理办法是用EditPlus另存为时,把编码格式由UTF-8改为ANSI. 然后 ...

  10. cmd命令汇总

    一  cmd 命令 cmd命令大全(第一部分) winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构(WMI) wupdmgr------ ...

随机推荐

  1. 字典树 - A Poet Computer

    The ACM team is working on an AI project called (Eih Eye Three) that allows computers to write poems ...

  2. compass Sprites 雪碧图 小图片合成[Sass和compass学习笔记]

    demo 源码 地址 https://github.com/qqqzhch/webfans 什么是雪碧图? CSS雪碧 即CSS Sprites,也有人叫它CSS精灵,是一种CSS图像合并技术,该方法 ...

  3. db2 import export load

    DB2中所谓的数据移动,包括: 1. 数据的导入(Import) 2. 数据的导出(Export) 3. 数据的装入(Load) 导入和装入都是利用DB2的相关命令把某种格式的文件中的数据保存到数据库 ...

  4. ZeroMQ接口函数之 :zmq_ipc – ZMQ本地进程间通信传输协议

    ZeroMQ API 目录 :http://www.cnblogs.com/fengbohello/p/4230135.html ——————————————————————————————————— ...

  5. 水坑式攻击-APT攻击常见手段

    所谓“水坑攻击”,是指黑客通过分析被攻击者的网络活动规律,寻找被攻击者经常访问的网站的弱点,先攻下该网站并植入攻击代码,等待被攻击者来访时实施攻击. 水坑攻击属于APT攻击的一种,与钓鱼攻击相比,黑客 ...

  6. 11.static关键字

    1.用static修饰的方法,直接用类调用 2.static修饰的方法只能调用static方法,不能调用非  static属性和方法 ①因为static属性和方法在类没有实例化的时候调用 ②因为普通属 ...

  7. Moses训练与测试

    参考:http://cache.baiducontent.com/c?m=9d78d513d9991cf00ffa940f47408f711925df252bd6a0502294ca5f92140d1 ...

  8. php操作数据库的简单示例

    放假期间自己又写了几个简单的网页,但在服务器中打开时和在网站上打开时不一样,在服务器中打开的出现了错误,字体比一般的腰大好多,页面也相应地变大了,一些块即使用了浮动和clear浮动还是被遮住了,我只好 ...

  9. IConfigurationSectionHandler 使用~

    读取webconfig中自定义的xml  处理对特定的配置节的访问. webconfig <configSections> <section name="NopConfig ...

  10. centos下JDK的卸载与安装

    linux是自带JDK的,但是它自带的JDK是openJDK,我们如果需要安装ant之类的软件,使用这个JDK是不行的.所以我们需要卸载linux下自带的JDK,并安装我们准备的JDK. JDK的卸载 ...