zoukankan      html  css  js  c++  java
  • Windows和linux环境下按文件名和字符串搜索命令

    Windows

    1.遍历C盘下所有txt

    命令:for  /r  c:  %i  in  (*.txt)  do  @echo  %i

    注释:for  循环的意思

       /r   按照路径搜索

       c:  路径

       %i in   (*.txt)  每一个txt文件

       do  @echo  就是输出

        %i  输出文件路径

    2.在C盘下搜索所有文件内容包含 demo 的文件

    命令:for  /r  c:  %a  in  (*)  do  @findstr  /im  "demo"  "%a"

    注释:%a  in  (*)  任何一个文件

       findstr  /im  按照字符串搜索

        "%a"      输出文件路径

    Linux(搜索时进入管理员权限)

    3.指定目录搜索--确定文件名

    命令:find  /etc  -name  1.c

    注释:find  查找

       /etc  路径

       -name 按照名称查找

       1.c    文件名称

    4.搜索文件名中带c的

    命令:find  /etc  -name  ‘*c*'

    注释:'*c*'  文件名只要有一个c就遍历出来

    5.从根目录开始查找所有扩展名为 .log 的文本文件,并找出包含“ERROR”的行

    命令:find  /  -type    f      -name  "*.log"  |     xargs     grep     "ERROR"

    注释:find  查找

       /    根目录

        -type   f  设置搜索的模式

       “*.log”  文件通配符

       xargs   grep   "ERROR"   并且包含“ERROR”的文件

    6.从根目录开始查找包含“main”的文件

    命令:grep  -r  "main"  /

    注释:grep  查找

       -r    按照路径查找

       “main” 查找的字符串

       /    根目录

  • 相关阅读:
    How to clean up BizTalk Message Box
    BizTalk: Database ‘BizTalkMsgBoxDb’ is full
    Install or Uninstall a Windows Service
    Distinguished Fields and Optional Elements
    Stay Hungry, Stay Foolish
    男子英文名大全,来历、释义
    Correlations in BizTalk 2004
    17.域环境解决方案
    18.windows痕迹清理
    Burpsuit手机抓包
  • 原文地址:https://www.cnblogs.com/xuewangkai/p/4328511.html
Copyright © 2011-2022 走看看