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------ ...
随机推荐
- iscrolljs 看API 回顾以前开发中失误
今天有空 细致的看看iscrolljs api 发现自己以前的几个失误是没看api造成的 失误1 页面a操作 影响了页面b的滚动条 api 解释: options.bindToWrapper The ...
- How To Handle a Loss of Confidence in Yourself
Do you feel like you've lost confidence in yourself? Have you had strong self doubts? Perhaps you we ...
- python之 sqlalchemy
one To many #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: zengchunyun & ...
- Daikon Forge GUI Library(dfgui)之Event Binding
点击按钮并弹出对话框,就用下面的大问题按钮吧 1,选中按钮,Component/Daikon Forge/Data Binding/Event Binding 2,UI上创建DfPanel,并将其Be ...
- percona-toolkit中在线ddl
percona-toolkit中在线ddl percona-toolkit工具提供了一组用于mysql操作的工具,比如主从复制,在线更改mysql表ddl等 一.安装1.安装perl(略)2.BI&a ...
- Yii2中数据过滤方案
1. 将数据赋值给model对象再通过model保存数据到数据库时有两种方法. 1) load()再save(). 这种可以通过$model->setScenario('test_scenari ...
- spring 另开线程时的注入问题
spring web项目在启动的时候,就会完成各种组件的注入.在工作的过程中,遇到了这样一个问题: 一个serviceA中要新开一个线程来执行一项任务(假定这个任务是ClassA).ClassA中要用 ...
- LeetCode Plus One Linked List
原题链接在这里:https://leetcode.com/problems/plus-one-linked-list/ 题目: Given a non-negative number represen ...
- (copy) Top Ten Reasons not to use the C shell
http://www.grymoire.com/Unix/CshTop10.txt ========================================================== ...
- php cUrl模拟登录,cookie保存到文件中
源码如下: <?php header("Content-Type:text/html;charset=utf-8"); //模拟群友通讯录手机号登录 $curl = curl ...