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
.
我有一个包含子文件夹的文件夹,它们都有很多类型的文件。我想在.css文件中搜索一个单词。我正在使用Windows 7而且我有grep。
How I can use grep
to :
我如何使用grep:
- Find pattern and print it
- 找到图案并打印出来
- Give file name (and path) if pattern found
- 如果找到模式,则提供文件名(和路径)
3 个解决方案
#1
30
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.
这将递归并查找子目录中的所有* .css,而-H将显示文件名。
#2
0
find folder/ -name "*.css" |xargs grep "your-pattern"
You will need to install cygwin to do this.
您需要安装cygwin才能执行此操作。
#3
0
if the files in which we have to look for, has pattern then we can use this. Consider I'm looking for pattern "cardlayout" in files named chap1.lst chap2.lst
and so on. then the command
如果我们要查找的文件有模式,那么我们可以使用它。考虑我在名为chap1.lst chap2.lst的文件中寻找模式“cardlayout”,依此类推。那么命令
grep -e 'cardlayout' ` find . -name "chap??.lst"`
hope this would help
希望这会有所帮助
#1
30
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.
这将递归并查找子目录中的所有* .css,而-H将显示文件名。
#2
0
find folder/ -name "*.css" |xargs grep "your-pattern"
You will need to install cygwin to do this.
您需要安装cygwin才能执行此操作。
#3
0
if the files in which we have to look for, has pattern then we can use this. Consider I'm looking for pattern "cardlayout" in files named chap1.lst chap2.lst
and so on. then the command
如果我们要查找的文件有模式,那么我们可以使用它。考虑我在名为chap1.lst chap2.lst的文件中寻找模式“cardlayout”,依此类推。那么命令
grep -e 'cardlayout' ` find . -name "chap??.lst"`
hope this would help
希望这会有所帮助