Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键 批量修改文件名等
http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html
linux下二进制文件查找:
strings 0000.ts | grep -o "T" | wc -l
grep _initcall_.*1$ ./aa > a1
2982 find . -regex '.*\.c|.*\.cxx|.*\.cpp|.*\.h'
2983 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h'
2984 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "malloc" -rn
2985 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "malloc" -rn > mem.malloc
2986 vim mem.malloc
2987 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "free" -rn > mem.free
2988 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "strdup" -rn > mem.strdup
2989 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "realloc" -rn > mem.realloc
2990 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "calloc" -rn > mem.calloc
2991 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "new" -rn > mem.new
2992 find . -regex '.*\.c\|.*\.cxx\|.*\.cpp\|.*\.h' | xargs grep "delete" -rn > mem.delete
批量修改文件名
rename 's/\.pkt/\.aac/' *
http://any2sky.blog.163.com/blog/static/468518032010914101851175/
将通过find命令找到的文件拷贝到一个新的目录中:
cp `find . -name "*pcm*.[c,h]"` tmp/ -rf
access.log.2011102[2-6]* 文件名的正则表达式,获取文件的条件
Linux下find一次查找多个指定文件或者排除某类文件,在 GREP 中匹配多个关键字的方法
(1)Linux下find一次查找多个指定文件:
查找a.html和b.html
- find . -name "a.html" -name "b.html"
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
- find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
- ./a.txt
- ./a.doc
- ./a.mp3
(2)排除某些文件类型:
排除目录下所有以html结尾的文件:
- find . -type f ! -name "*.html"
- find . -type f ! -name "*.html"
- ./ge.bak.02.09
- ./ge.html.changed.by.jack
- ./a.txt
- ./a.doc
- ./a.mp3
(3)排除多种文件类型的示例:
- find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.o" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"
(3)在 GREP 中匹配多个关键字的方法:
grep查找多个数字的文件:
-r 递归,-E:正则 -l:只显示文件名
- root@116.255.139.240:~/a# grep -r -E '0341028|100081|10086|10001' *
- a.txt:100081
- b.txt:10086
- c/cc.txt:0341028
- c/cc.txt:100081
- c/cc.txt:10086
- c/cc.txt:10001
- c.txt:10001
- d.txt:0341028
- grep -r -E -l '0341028|100081|10086|10001' *
- a.txt
- b.txt
- c/cc.txt
- c.txt
- d.txt
多种类型文件示例:
- find . -name "*.html" -o -name "*.js"|xargs grep -r "BusiTree"
用Awk:
- find . -name "*.php"|awk '{print "cat " $0 " |grep -H dbsys.mxxxx.justwinit.cn"}'|sh
Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键 批量修改文件名等的更多相关文章
- linux 下用find命令查找文件,rm命令删除文件
linux 下用find命令查找文件,rm命令删除文件. 删除指定目录下指定文件find 要查找的目录名 -name .svn |xargs rm -rf 删除指定名称的文件或文件夹: find -t ...
- Linux下批量修改文件名(rename)
原文地址: http://blog.csdn.net/sea_shore/article/details/6102437 1.rename命令批量修改文件名, 其实linux下可以使用别的办法来批量修 ...
- linux批量修改文件名的shell脚本
linux中批量修改文件名的shell脚本代码,主要是使用了rename,结合shell,喜欢的朋友可以参考下 使用 rename 命令 ======================== NAME ...
- linux 批量修改文件名 文件名只保留部分,去掉部分
问题:linux系统中文件名包含中文,导致页面访问不了文件.就是上条博客中的解决方法二遗留问题. 文件名中有以下格式:TC2_诺而达铜管(中山)有限公司.pdf ,要改为TC2.pdf,去掉中文部分 ...
- windows下如何批量修改文件名
windows下如何批量修改文件名 一.总结 一句话总结:就是用excel生成了多条修改文件名的dos命令然后执行,比较核心的就是把图片名称导入excel 将图片名称导入excel---编写如下DOS ...
- Linux下的五个查找命令:grep、find、locate、whereis、which
原文转自 http://www.cnblogs.com/wanqieddy/archive/2011/07/15/2107071.html 1.grep grep(General Regular Ex ...
- linux下的5个查找命令
在Linux中,有很多方法可以做到这一点.国外网站LinuxHaxor总结了五条命令,你可以看看自己知道几条.大多数程序员,可能经常使用其中的2到3条,对这5条命令都很熟悉的人应该是不多的. 1. f ...
- linux -- Linux下的五个查找命令:grep、find、locate、whereis、which
1.grep grep(General Regular Expression Parser,通用规则表达式分析程序)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来. 它的使 ...
- Linux下onvi支持h265环境的的搭建:gsoap的安装及生产.c .h文件
1. 下载gsoap :http://www.genivia.com/products.html#notice,既Open Source gSOAP版本,并解压进入目录安装,configure后面 ...
随机推荐
- [转]NHibernate之映射文件配置说明
1. hibernate-mapping 这个元素包括以下可选的属性.schema属性,指明了这个映射所引用的表所在的schema名称.假若指定了这个属性, 表名会加上所指定的schema的名字扩展为 ...
- Java Day 16
基本数据类型包装类 Integer.MAX_VALUE Integer.parseInt(); intValue(); valueOf(); 自动装拆箱 如果是一个字节范围,数据共享 字符串中 数值 ...
- MATLAB中匿名函数与符号函数的转换
符号函数举例: syms x y=x+1; y1=diff(y); %求导 匿名函数举例: z=@(x)(x(1)+2*x(2)); t=z([2 3]); %计算z在x=[2 3]处的值 z=@(x ...
- Machine Learning 学习笔记 (2) —— 使用牛顿法寻找极值
本系列文章允许转载,转载请保留全文! [请先阅读][说明&总目录]http://www.cnblogs.com/tbcaaa8/p/4415055.html 1. 用牛顿法解方程 牛顿法是一种 ...
- LintCode-Serialization and Deserialization Of Binary Tree
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a ...
- PostgreSQL中的引号和null
今天工作时写了一个sql,但是PostgreSQL总是提示有语法错误,简单的做个记录: 问题1.'' 和“”单引号和双引号 举个例子: #.select id, delivery_d ...
- Gentoo安装配置过程与总结
前些时间在VMware上安装了Gentoo Linux,用了当前最新版的Gentoo,安装过程记录下来了,但一直没有整理到blog上.今天重新整理一下,写出来与大家分享和备用.接触Gentoo不久,对 ...
- android 系统应用在运行时被卸载
android 系统应用在运行时被rm 掉了,是否还会运行? 环境:root,且开机运行 经过试验,apk本身是在 /system/app 目录下面,且apk已经运行了,这个时候直接 rm /syst ...
- java list中的对象,按对象某属性排序
1:对象类 需要 实现: public class TreeNode extends BaseBean implements Comparable <TreeNode> { private ...
- SQL Server表分区案例
--学习创建表分区脚本/*SQL SERVER 2005中以上版本,终于引入了表分区,就是说,当一个表里的数据很多时,可以将其分拆到多个的表里,大大提高了性能.下面举例子说明之*/ --------- ...