简体   繁体   English

如何在文件夹中的所有文件中搜索特定短语?

[英]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.

相关问题 如何在大量.js和.php文件中搜索特定短语? - how can i search a lots of .js and .php files for a specific phrase? 如何使用 PowerShell 搜索特定文件名然后将该文件之后的所有文件移动到另一个文件夹 - How to search for a specific file name then move all files after that file to another folder using PowerShell 如何在VS Code的文件夹中列出特定扩展名的所有文件? - How to list all the files of a specific extension in a folder in VS Code? 如何创建一个bash脚本,它将小写当前文件夹中的所有文件,然后搜索/替换所有文件? - How to create a bash script that will lower case all files in the current folder, then search/replace in all files? 使用php在文本文件中搜索短语/单词 - Search for phrase/word in text files with php 批处理文件以搜索文件夹并删除特定文件 - Batch file to search through a folder and delete specific files 如何在所有文件中搜索字符串 - How to search for a string in all files 如何使用grep和字符串在多个文件中搜索单个单词或短语? - How can I search multiple files for a single word or phrase using grep and strings? 搜索文件夹和所有子文件夹中的特定文件类型 - search folder and all sub folders for a specific file type Box.com Search API 可检索确定文件夹中的所有文件 - Box.com Search API to retrieve all files in a determined folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM