[英]How to search specific phrase in all files in folder?
I'm a web dev and sometimes I have a very difficult time to find specific line in code.我是 web 开发人员,有时我很难在代码中找到特定的行。
Is there any possibility on Mac to search for specific text for exp.在 Mac 上是否有可能为 exp 搜索特定文本。 "1234567890" in any files included in specific folder?特定文件夹中包含的任何文件中的“1234567890”?
Best Regards此致
Following should work on a mac.以下应该在mac上工作。
Search for a string in a single file:在单个文件中搜索字符串:
cat ./file_name | grep "string"
Search for a string in all files in a single directory在单个目录中的所有文件中搜索字符串
grep "string" *
Search for a string in all files in a directory (and sub-directories):在目录(和子目录)的所有文件中搜索字符串:
grep -r "string"
Also, if you're using an IDE, most of them have built in support for that type of search.此外,如果您使用的是 IDE,它们中的大多数都内置了对此类搜索的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.