zoukankan      html  css  js  c++  java
  • Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键

    转载:http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html

     

    Linux下find一次查找多个指定文件或者排除某类文件,在 GREP 中匹配多个关键字的方法
    (1)Linux下find一次查找多个指定文件:
    查找a.html和b.html

    1. find . -name "a.html"  -name "b.html"  


    find . -regex '.*.txt|.*.doc|.*.mp3'

    1. find . -regex '.*.txt|.*.doc|.*.mp3'  
    2. ./a.txt  
    3. ./a.doc  
    4. ./a.mp3  


    (2)排除某些文件类型:
    排除目录下所有以html结尾的文件:

    1. find . -type f ! -name "*.html"    

     

    1. find . -type f ! -name "*.html"       
    2. ./ge.bak.02.09  
    3. ./ge.html.changed.by.jack  
    4. ./a.txt  
    5. ./a.doc  
    6. ./a.mp3  


    (3)排除多种文件类型的示例:

    1. 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:只显示文件名

    1. root@116.255.139.240:~/a# grep -r -E '0341028|100081|10086|10001' *  
    2. a.txt:100081  
    3. b.txt:10086  
    4. c/cc.txt:0341028  
    5. c/cc.txt:100081  
    6. c/cc.txt:10086  
    7. c/cc.txt:10001  
    8. c.txt:10001  
    9. d.txt:0341028  

     

    1. grep -r  -E -l '0341028|100081|10086|10001' *     
    2. a.txt  
    3. b.txt  
    4. c/cc.txt  
    5. c.txt  
    6. d.txt  


    多种类型文件示例:

    1. find . -name "*.html" -o -name "*.js"|xargs grep -r "BusiTree"   



    用Awk:

    1. find . -name "*.php"|awk '{print "cat " $0 " |grep -H dbsys.mxxxx.justwinit.cn"}'|sh  


    参考本站:http://justwinit.cn/post/714/

  • 相关阅读:
    textdecoration、textdecorationcolor、textdecorationline、textdecorationstyle属性
    深入解读Promise对象
    如何将WCF服务发布到IIS中去VS2010版
    iPhone 常用面试题目
    WCF入门简单教程(图文) VS2010版
    VS2010中如何创建一个WCF
    ObjC: 使用KVO
    iOS面试重点问题
    iOS开发面试题
    《Iphone开发基础教程》第五章 自动旋转和调整大小
  • 原文地址:https://www.cnblogs.com/pengdonglin137/p/3766328.html
Copyright © 2011-2022 走看看