At Linux command line, to find a particular text string in all the files from the current directory recursively (that is, including all those files from the child or grandchild directories), use something like this via SSH:
find . -exec grep -l "needle" {} \;
This command searches through all directories from the current directory recursively for the files that contain the string “needle”.
To search only .php files:
find *.php -exec grep -l "needle" {} \;
To search a specific directory:
find dirname -exec grep -l "needle" {} \;
To find all .php files that contain “needle” in all the directories under “somedir”:
find somedir -name *.php -exec grep -l "needle" {} \;
Related Posts
- Linux: Check how much disk storage each directory takes up (Disk Usage command – du)
- Linux: Find files changed or modified within 1 day or older than 1 day
- Essential SSH – 19 Linux SSH Commands You Simply Cannot Live Without
- Linux: Change Directory or CD to the Previous Directory / Last Path
- Linux: How to open and extract an RAR zipped file and unrar the archive?

{ 1 comment… read it below or add one }
BTW, if it spits out this error:
Embrace necessary parameters in double quotes “”. E.g.,