在 Windows 中,我会进行搜索以在文件夹中查找单词。同样,我想知道某个特定单词是否出现在包含许多子目录和文件的目录中。我对 grep 语法的搜索显示我必须指定文件名,即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*' .
末尾的点搜索当前目录。每个参数的含义:
-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*' .
(会发现MobileAppServlet.java
or MobileAppServlet.class
or MobileAppServlet.txt
; 'MobileAppASer*.*'
是做同样事情的另一种方法。)
要检查更多参数,请使用man grep命令。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)