使用grep在多个文件中查找字符串 [英] Find a string in multiple files using grep

查看:653
本文介绍了使用grep在多个文件中查找字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含子文件夹的文件夹,都有很多类型的文件。我想在 .css 文件中搜索一个单词。我正在使用Windows 7,并且我有 grep



我可以如何使用 grep 到:


  1. 查找模式并打印它

  2. 和路径)如果发现模式


解决方案

实际上,您不需要查找。只需使用:

  grep -R --include = *。css -H模式。 

这会在子目录中递归查找所有* .css,而-H将显示文件名。

I have a folder with sub-folders inside, all have many types of files. I want to search for a word inside the .css-files. I am using Windows 7 and I have grep.

How I can use grep to :

  1. Find pattern and print it
  2. Give file name (and path) if pattern found

解决方案

Actually you don't need find. Just use:

grep -R --include=*.css -H pattern .

this will recurse and look for all *.css in subdirectories, while -H will show the filename.

这篇关于使用grep在多个文件中查找字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆