我如何使用grep在文件夹中查找单词? [英] How can I use grep to find a word inside a folder?
问题描述
grep string filename
。 现在,我不知道文件名,那我该怎么办?
朋友建议做 grep -nr string
,但我不知道这意味着什么,我没有得到任何结果(直到我没有回应发布一个 ctrl + c )。
grep - nr'yourString *'。
最后的点搜索当前目录。每个参数的含义:
-n在文件中显示相对行号
'yourString *'用于搜索的字符串,后跟一个通配符
-r递归搜索列出的
子目录。搜索目录(当前目录)
grep -nr'MobileAppSer *'。
(会发现 MobileAppServlet.java
或 MobileAppServlet.class
或 MobileAppServlet.txt
; 'MobileAppASer *。*'
是另一种做同样事情的方法。)
要检查更多参数,请使用 man grep 命令。
In Windows, I would have done a search for finding a word inside a folder. Similarly, I want to know if a specific word occurs inside a directory containing many sub-directories and files. My searches for grep syntax shows I must specify the filename, i.e. grep string filename
.
Now, I do not know the filename, so what do I do?
A friend suggested to do grep -nr string
, but I don't know what this means and I got no results with it (there is no response until I issue a ctrl + c).
grep -nr 'yourString*' .
The dot at the end searches the current directory. Meaning for each parameter:
-n Show relative line number in the file
'yourString*' String for search, followed by a wildcard character
-r Recursively search subdirectories listed
. Directory for search (current directory)
grep -nr 'MobileAppSer*' .
(Would find MobileAppServlet.java
or MobileAppServlet.class
or MobileAppServlet.txt
; 'MobileAppASer*.*'
is another way to do the same thing.)
To check more parameters use man grep command.
这篇关于我如何使用grep在文件夹中查找单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!