Problem: fast search some code blocks in big projects with lots of nested directories using command-line tools.
Solving: you need grep command. Its really great tool for search text in files with regular expressions, coming from Unix OS and now available on Windows, *nix and Mac OS. All you need is:
So, let's consider parameters passed to grep command:
If you need just filenames without in-line matches, you can use parameter -l:
That's all - good luck in your search:)
Solving: you need grep command. Its really great tool for search text in files with regular expressions, coming from Unix OS and now available on Windows, *nix and Mac OS. All you need is:
grep -rin --include="*.php" "function Action(" /path/to/directory/
So, let's consider parameters passed to grep command:
-r
— the search will be recursive, that is in all subdirectories in our main directory-i
— the search will be case insensitive-n
— output will contain line numbers--include="*.php"
— search will be only in files that has php extension. Of course, available all regular expressions for describing needed file names"function Action("
— needed text/path/to/directory
— directory for search accordingly
If you need just filenames without in-line matches, you can use parameter -l:
grep -rinl --include="*.php" "function Action(" /path/to/directory/
That's all - good luck in your search:)
Комментариев нет:
Отправить комментарий