find命令递归查找
Probably a dozen times a day I need to search any given project for specific code keywords. Most of the time it's within a specific project but then there are times where I don't remember which directory or project the specific text is -- from my blog to my many Mozilla projects, I have code all over my local machine and it's oftentimes difficult to find something I need.
大概每天需要十几次,我需要在任何给定的项目中搜索特定的代码关键字。 多数情况下,它在特定项目中,但是有时我不记得特定文本在哪个目录或项目中-从我的博客到我的许多Mozilla项目,我在本地计算机上都拥有代码,而且通常很难找到我需要的东西。
Most of the time I need to open my text editor and have it do the hard work of what I'm looking for but that's probably not efficient -- a more efficient tool would come from command line and thanks to , I found the perfect command:
大多数时候,我需要打开文本编辑器并让它完成我要查找的内容,但是这可能效率不高-一个更高效的工具将来自命令行,这要归功于 ,我发现完美的命令:
# Search all ".js" files for "debounce"# Spits out file path, line number, and snippet where string appearsfind . -name "*.js" -exec grep -in -H "debounce" {} \;
The command above searches files recursively to find the desired string, outputting the source file and the text which the string occurs in!
上面的命令以递归方式搜索文件以找到所需的字符串,输出源文件和该字符串所在的文本!
翻译自:
find命令递归查找