2010-07-13 09:42:08 +0000 2010-07-13 09:42:08 +0000

答案 (5)

解决方案找到了!

得分 299
2010-07-13 09:47:11 +0000
grep -r 'text goes here' path_goes_here
Advertisement
得分 31
2010-08-12 22:38:59 +0000

使用聚光灯

mdfind "text goes here"
mdfind -onlyin /home/user/Desktop -live "live update"

别忘了看:

man mdfind
Advertisement
得分 12
2016-03-03 14:07:18 +0000
Advertisement
  1. 通过Ack
brew install ack 
ack "text goes here"
  1. 通过 find
find . |grep "text goes here"
  1. 通过 grep
grep -RnslI "text goes here"
``` &001
得分 4
2017-06-01 08:00:18 +0000

你可以根据自己的喜好和需求,选择下面的一种方式。假设你需要在当前目录中递归搜索包含文本的文件–“async",你可以用下面的一种方式来实现。

使用grep* enter image description here

使用ack* enter image description here

Advertisement
得分 2
2017-06-01 15:27:29 +0000
Advertisement

Ignacio的回答很好,帮助我找到了包含某些文本的文件。我遇到的唯一问题是,当运行这个命令时,所有的文件都会被列出,其中包括一个没有显示图案的文件。

如果你在命令中加入No such file or directory,如:-s ; grep -lr "text pattern" ./ -s,它将只显示出包含图案的文件。如何让grep不打印出 “No such file or directory "错误?](https://stackoverflow.com/questions/6426363/how-can-i-have-grep-not-print-out-no-such-file-or-directory-errors)