zoukankan      html  css  js  c++  java
  • 在文件夹下所有文件中查找字符串(linux/windows)

    在linux下可以用 

    grep "String" filename.txt
    #字符串 文件名
    grep -r "String" /home/
    #递归查找目录下所有文件
    来查找单个文件或者目录下所有文件是否包含某个字符串

    windows下同样可以实现类似功能

    findstr可以完成这个工作。

    findstr /s /i "string" *.*
    上面的命令表示,当前目录以及当前目录的所有子目录下的所有文件中查找"string"这个字符串。

    *.*表示所有类型的文件。

    /s 表示当前目录以及所有子目录

    /i 表示不区分大小写

    可以参考help findstr的输出解释来使用此命令。

    注意:

    findstr.exe一般在C:WindowsSystem32目录下,要从任意路径调用该命令,需要将C:WindowsSystem32添加到path环境变量中,如果没加环境变量可以这样用

    C:WindowsSystem32findstr.exe /s /i "string" *.*

  • 相关阅读:
    CodeForces
    codeforces 1250B The Feast and the Bus
    CF1038D Slime
    CodeForces-208C Police Station
    差分约束
    HDU 2586
    HDU 3948
    HDU 2222
    作业
    闰年的判断
  • 原文地址:https://www.cnblogs.com/bensonyang/p/12010205.html
Copyright © 2011-2022 走看看